/* DevAviation CRM — matches devaviation.uk palette */
:root {
  --navy: #1a3552;
  --navy-deep: #0f2238;
  --sky: #4a90c4;
  --gold: #d4a843;
  --background: #fafbfc;
  --foreground: #1a2332;
  --card: #ffffff;
  --border: #dde4ea;
  --muted: #f2f5f7;
  --muted-foreground: #5c6b7a;
  --primary: var(--navy);
  --primary-foreground: #f8fafc;
  --secondary: #eef2f6;
  --accent: var(--sky);
  --destructive: #c0392b;
  --radius: 12px;
  --shadow: 0 12px 40px rgba(15, 34, 56, 0.08);
  --font: "Inter", system-ui, sans-serif;
  --font-display: "Sora", var(--font);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

a { color: var(--navy); }

.hidden { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.1rem;
  border-radius: 8px;
  border: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}
.btn-primary:hover { background: var(--navy-deep); }

.btn-ghost {
  background: transparent;
  color: var(--foreground);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--muted); }

.btn-sm { padding: 0.45rem 0.75rem; font-size: 0.82rem; }
.btn-block { width: 100%; }

.icon-btn {
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted-foreground);
}
.icon-btn:hover { background: var(--muted); color: var(--foreground); }

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--foreground);
}

input, select, textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  margin-bottom: 0.9rem;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(74, 144, 196, 0.35);
  border-color: var(--sky);
}

textarea { min-height: 96px; resize: vertical; }

.form-banner {
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.form-error { background: rgba(192, 57, 43, 0.1); color: #8b2e24; }

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(165deg, rgba(15, 34, 56, 0.95), rgba(26, 53, 82, 0.88)),
    radial-gradient(circle at top right, rgba(74, 144, 196, 0.25), transparent 50%);
}

.login-shell { width: min(100%, 420px); padding: 1.5rem; }

.login-card {
  background: var(--card);
  border-radius: calc(var(--radius) + 4px);
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.login-brand img { border-radius: 8px; }

.login-brand strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.login-brand span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-foreground);
}

.login-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.6rem;
}

.login-lead {
  margin: 0 0 1.25rem;
  color: var(--muted-foreground);
  font-size: 0.95rem;
}

/* App layout */
.crm-app { min-height: 100vh; }

.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--navy-deep);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem 1.25rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
}

.sidebar-brand img { border-radius: 6px; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.active {
  background: rgba(74, 144, 196, 0.22);
  color: #fff;
}

.nav-icon { opacity: 0.85; }

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 1rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: var(--sky);
  display: grid;
  place-items: center;
  font-size: 0.82rem;
  font-weight: 700;
}

.user-chip strong {
  display: block;
  font-size: 0.88rem;
}

.user-chip span {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
}

.main-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--sky);
  font-weight: 600;
}

.topbar h1 {
  margin: 0.15rem 0 0;
  font-size: 1.5rem;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.search-wrap input {
  margin: 0;
  min-width: 240px;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.toggle-btn {
  border: none;
  background: #fff;
  padding: 0.55rem 0.85rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted-foreground);
}

.toggle-btn.active {
  background: var(--secondary);
  color: var(--foreground);
}

.workspace {
  padding: 1.25rem 1.5rem 2rem;
  flex: 1;
}

/* Table */
.data-table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  background: var(--muted);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: rgba(74, 144, 196, 0.06); }

.stage-pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--secondary);
  color: var(--navy);
}

.stage-pill.won { background: rgba(39, 174, 96, 0.15); color: #1e7e4a; }
.stage-pill.lost { background: rgba(192, 57, 43, 0.12); color: #8b2e24; }

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted-foreground);
}

/* Pipeline kanban */
.pipeline-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 1fr);
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.pipeline-column {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 420px;
  display: flex;
  flex-direction: column;
}

.pipeline-column-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.pipeline-column-header h3 {
  margin: 0;
  font-size: 0.88rem;
}

.pipeline-count {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted-foreground);
  background: #fff;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
}

.pipeline-cards {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex: 1;
}

.pipeline-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}

.pipeline-card:hover {
  box-shadow: 0 8px 24px rgba(15, 34, 56, 0.08);
  transform: translateY(-1px);
}

.pipeline-card strong {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 0.25rem;
}

.pipeline-card span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted-foreground);
}

/* Detail view */
.detail-view {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
}

.detail-back {
  grid-column: 1 / -1;
  margin-bottom: 0.25rem;
}

.detail-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.detail-card h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1rem;
}

.detail-field label {
  margin-bottom: 0.15rem;
  color: var(--muted-foreground);
  font-weight: 500;
}

.detail-field p {
  margin: 0;
  font-weight: 600;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-list li {
  background: var(--secondary);
  color: var(--navy);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.timeline-item {
  border-left: 2px solid var(--border);
  padding-left: 0.85rem;
}

.timeline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-bottom: 0.25rem;
}

.timeline-type {
  font-weight: 700;
  color: var(--sky);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.timeline-item p {
  margin: 0;
  font-size: 0.9rem;
  white-space: pre-wrap;
}

.activity-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.activity-form h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

/* Modal */
.modal {
  border: none;
  border-radius: calc(var(--radius) + 2px);
  padding: 0;
  width: min(560px, calc(100vw - 2rem));
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(15, 34, 56, 0.45);
}

.modal-body { padding: 0; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-fields {
  padding: 1.25rem;
  max-height: 65vh;
  overflow: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.checkbox-grid {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.9rem;
}

.checkbox-grid label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-weight: 500;
  margin: 0;
}

.checkbox-grid input {
  width: auto;
  margin: 0.15rem 0 0;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.settings-intro {
  margin: 0 0 1rem;
  color: var(--muted-foreground);
  font-size: 0.95rem;
}

@media (max-width: 960px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 20; }
  .sidebar-nav { flex-direction: row; overflow-x: auto; }
  .sidebar-footer { display: none; }
  .detail-view { grid-template-columns: 1fr; }
  .search-wrap input { min-width: 180px; }
}

@media (max-width: 640px) {
  .topbar { padding: 1rem; }
  .workspace { padding: 1rem; }
  .detail-grid { grid-template-columns: 1fr; }
}
