/* =============================================================================
   MEDIALUX CRM — Design system
   Neutral premium palette · dark / light · DOOH operator aesthetic
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Instrument+Serif:ital@0;1&display=swap');

:root {
  --font-sans: 'DM Sans', system-ui, sans-serif;
  --font-display: 'Instrument Serif', Georgia, serif;

  --bg: #f4f5f7;
  --bg-elevated: #ffffff;
  --bg-muted: #ebeef2;
  --bg-sidebar: #0f1218;
  --bg-sidebar-hover: #1a1f2a;
  --border: #e2e5eb;
  --border-strong: #c8ced8;

  --text: #12151c;
  --text-secondary: #5c6575;
  --text-muted: #8b93a3;
  --text-on-dark: #e8eaef;
  --text-on-dark-muted: #9aa3b5;

  --accent: #c4a574;
  --accent-hover: #b08f5c;
  --accent-soft: rgba(196, 165, 116, 0.14);

  --success: #2f9e6b;
  --success-soft: rgba(47, 158, 107, 0.12);
  --warning: #c4862a;
  --warning-soft: rgba(196, 134, 42, 0.14);
  --danger: #c44b4b;
  --danger-soft: rgba(196, 75, 75, 0.12);
  --info: #3d7ea6;
  --info-soft: rgba(61, 126, 166, 0.12);

  --live: #2f9e6b;
  --shadow: 0 1px 2px rgba(15, 18, 24, 0.04), 0 8px 24px rgba(15, 18, 24, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 260px;
  --header-h: 64px;
  --transition: 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --bg: #0b0d11;
  --bg-elevated: #141820;
  --bg-muted: #1c222d;
  --bg-sidebar: #080a0e;
  --bg-sidebar-hover: #151a24;
  --border: #252b36;
  --border-strong: #343c4a;

  --text: #eef0f4;
  --text-secondary: #a0a8b8;
  --text-muted: #6e7789;
  --text-on-dark: #eef0f4;
  --text-on-dark-muted: #8b94a7;

  --accent: #d4b896;
  --accent-hover: #e0c6a8;
  --accent-soft: rgba(212, 184, 150, 0.12);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.35);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(61, 126, 166, 0.06), transparent 50%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; display: block; }

/* ----- Layout ----- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  color: var(--text-on-dark);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition), width var(--transition);
  border-right: 1px solid rgba(255,255,255,0.04);
}

.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); }

.sidebar-brand {
  padding: 1.1rem 1.4rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand-link {
  display: block;
  line-height: 0;
}

.sidebar-logo {
  display: block;
  width: auto;
  max-width: 100%;
  height: 3.35rem;
  object-fit: contain;
  object-position: left center;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
}

.nav-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-on-dark-muted);
  padding: 0.75rem 0.75rem 0.4rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-on-dark-muted);
  font-weight: 500;
  margin-bottom: 2px;
  transition: background var(--transition), color var(--transition);
}

.nav-link:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-on-dark);
}

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-link svg {
  width: 18px;
  height: 18px;
  opacity: 0.85;
  flex-shrink: 0;
}

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

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

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8a6d45);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 0.8rem;
  color: #0f1218;
}

.user-meta { min-width: 0; }
.user-meta .name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-on-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-meta .role {
  font-size: 0.7rem;
  color: var(--text-on-dark-muted);
}

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  transition: margin-left var(--transition);
}

.main.expanded { margin-left: 0; }

.topbar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 400;
  margin: 0;
  letter-spacing: 0.01em;
}

.content {
  padding: 1.5rem;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform 100ms ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: #0f1218;
}
.btn-primary:hover { background: var(--accent-hover); color: #0f1218; }

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { border-color: var(--border-strong); background: var(--bg-muted); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-muted); color: var(--text); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.btn-icon:hover { border-color: var(--border-strong); color: var(--text); }

/* ----- Cards / surfaces ----- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: visible;
}

.card-body { padding: 1.15rem 1.25rem; overflow: visible; }
.card-header {
  padding: 0.95rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-header h2, .card-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  position: relative;
  overflow: hidden;
  animation: riseIn 0.45s var(--transition) both;
}

.kpi-card::after {
  content: '';
  position: absolute;
  inset: auto -20% -40% auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--accent-soft);
  pointer-events: none;
}

.kpi-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 1.85rem;
  margin-top: 0.35rem;
  line-height: 1.15;
}

.kpi-hint {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
}

/* ----- Company field + profile link ----- */
.company-field-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.company-field-row .search-select {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}
.company-profile-link {
  flex: 0 0 auto;
  white-space: nowrap;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
}

/* ----- Searchable select ----- */
.search-select {
  position: relative;
  width: 100%;
}
.search-select-input,
input.search-select-input[type="search"] {
  width: 100%;
  padding: 0.6rem 2.25rem 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}
.search-select-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-select::after {
  content: '';
  position: absolute;
  right: 0.9rem;
  top: 50%;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.search-select-list {
  position: absolute;
  z-index: 50;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.search-select-list li {
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text);
}
.search-select-list li:hover,
.search-select-list li.is-active {
  background: var(--accent-soft);
  color: var(--text);
}
.search-select-list li[aria-selected="true"] {
  font-weight: 600;
  color: var(--accent-hover);
}
.search-select-empty {
  position: absolute;
  z-index: 50;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
/* ----- Choice cards (pacotes / duração — estilo medialux.pt) ----- */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}
.choice-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}
.choice-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.choice-card:hover {
  border-color: var(--border-strong);
}
.choice-card.is-selected,
.choice-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}
.choice-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.choice-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}
.choice-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.35;
}
.choice-tag {
  align-self: flex-start;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-hover);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
}
.computed-date {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  font-weight: 600;
  min-height: 2.5rem;
  display: flex;
  align-items: center;
}
@media (max-width: 900px) {
  .choice-grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .choice-grid,
  .choice-grid-4 { grid-template-columns: 1fr; }
}

/* ----- Status chips (non-blocking inline hints) ----- */
.status-chip {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  border: 1px solid transparent;
}
.status-chip.ok { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.status-chip.warn { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.status-chip.err { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }

/* ----- Modal ----- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, visibility 180ms ease;
}
.modal-root.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 18, 24, 0.55);
  backdrop-filter: blur(4px);
}
.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.4rem 1.2rem;
  transform: translateY(10px) scale(0.98);
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
  animation: none;
}
.modal-dialog.is-wide {
  width: min(640px, 100%);
}
.modal-preview-meta {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.modal-preview-label {
  display: block;
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.modal-preview-editor {
  display: block;
  width: 100%;
  min-height: 220px;
  max-height: min(50vh, 420px);
  margin: 0 0 0.35rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.5;
  resize: vertical;
  overflow: auto;
  white-space: pre-wrap;
}
.modal-preview-editor.is-html {
  white-space: normal;
  background: #fff;
  color: #1a1d24;
}
.modal-preview-editor:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.modal-preview-editor.is-invalid {
  border-color: var(--danger);
}
.modal-root.is-open .modal-dialog {
  transform: translateY(0) scale(1);
}
.modal-dialog[data-type="success"] { border-top: 3px solid var(--success); }
.modal-dialog[data-type="error"] { border-top: 3px solid var(--danger); }
.modal-dialog[data-type="warning"] { border-top: 3px solid var(--warning); }
.modal-dialog[data-type="info"] { border-top: 3px solid var(--info); }
.modal-dialog[data-type="confirm"] { border-top: 3px solid var(--accent); }
.modal-title {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--text);
}
.modal-body {
  margin: 0 0 1.25rem;
  color: var(--text-secondary);
  font-size: 0.925rem;
  line-height: 1.5;
}
.modal-message {
  margin: 0;
  white-space: pre-wrap;
}
.modal-input {
  display: block;
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}
.modal-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.modal-input.is-invalid {
  border-color: var(--danger);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-alert { background: var(--danger-soft); color: var(--danger); }
.badge-renewal { background: var(--warning-soft); color: var(--warning); }
.badge-inactive { background: var(--bg-muted); color: var(--text-muted); border: 1px solid var(--border); }
.badge-live { background: var(--success-soft); color: var(--live); }
.badge-neutral { background: var(--bg-muted); color: var(--text-secondary); }

.list-tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.list-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
}
.list-tab:hover { color: var(--text); }
.list-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.list-tab-count {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--text-secondary);
}
.list-tab.is-active .list-tab-count {
  background: var(--accent-soft);
  color: var(--accent);
}

.stage-pill {
  display: inline-flex;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
}

.stage-lead { background: #e8ecf2; color: #4a5568; }
.stage-contacted { background: #dde8f5; color: #2f5f8a; }
.stage-proposal { background: #f5ecd8; color: #8a6520; }
.stage-won { background: #d8f0e4; color: #1f7a4f; }
.stage-creative { background: #efe4f5; color: #6b3d8a; }
.stage-live { background: #d4f5e4; color: #157a4a; }
.stage-completed { background: #e5e7eb; color: #4b5563; }
.stage-lost { background: #f5dede; color: #9b3030; }

[data-theme="dark"] .stage-lead { background: #2a303c; color: #c0c7d4; }
[data-theme="dark"] .stage-contacted { background: #1e3348; color: #8eb8dc; }
[data-theme="dark"] .stage-proposal { background: #3a3120; color: #d4b06a; }
[data-theme="dark"] .stage-won { background: #1c3a2c; color: #6dcea0; }
[data-theme="dark"] .stage-creative { background: #322640; color: #c4a0e0; }
[data-theme="dark"] .stage-live { background: #163528; color: #5ed49a; }
[data-theme="dark"] .stage-completed { background: #2a2f38; color: #9aa3b2; }
[data-theme="dark"] .stage-lost { background: #3a2222; color: #e09090; }

/* ----- Tables ----- */
.table-wrap { overflow-x: auto; }

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

table.data th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}

table.data th.is-sortable {
  cursor: pointer;
  user-select: none;
  padding-right: 1.35rem;
  position: relative;
}
table.data th.is-sortable:hover { color: var(--text); }
table.data th.is-sortable::after {
  content: '⇅';
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  opacity: 0.35;
}
table.data th.is-sortable[aria-sort="ascending"]::after {
  content: '↑';
  opacity: 0.9;
  color: var(--accent);
}
table.data th.is-sortable[aria-sort="descending"]::after {
  content: '↓';
  opacity: 0.9;
  color: var(--accent);
}

table.data td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data tbody tr {
  transition: background var(--transition);
}
table.data tbody tr:hover { background: var(--bg-muted); }
table.data tbody tr:last-child td { border-bottom: none; }

/* ----- Forms ----- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.search-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.search-bar input { max-width: 280px; }

/* ----- Kanban ----- */
.kanban-board {
  display: flex;
  gap: 0.85rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: calc(100vh - 180px);
  scroll-snap-type: x proximity;
}

.kanban-col {
  flex: 0 0 260px;
  background: var(--bg-muted);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 180px);
  scroll-snap-align: start;
}

.kanban-col-header {
  padding: 0.85rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-muted);
  border-radius: var(--radius) var(--radius) 0 0;
  z-index: 2;
}

.kanban-col-header h3 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
}

.kanban-count {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  color: var(--text-secondary);
}

.kanban-cards {
  padding: 0.65rem;
  overflow-y: auto;
  flex: 1;
  min-height: 120px;
}

.kanban-cards.drag-over {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
  border-radius: var(--radius-sm);
}

.kanban-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  margin-bottom: 0.55rem;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: box-shadow var(--transition), transform var(--transition), opacity var(--transition);
  user-select: none;
}

.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.45; transform: scale(0.98); }
.kanban-card:hover { box-shadow: var(--shadow); }

.kanban-card .title {
  font-weight: 600;
  font-size: 0.875rem;
  margin: 0 0 0.35rem;
  color: var(--text);
}

.kanban-card .meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.kanban-card .value {
  margin-top: 0.55rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
}

.kanban-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.btn-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-link:hover { color: var(--danger); }

/* ----- Company contacts ----- */
.contact-row {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}
.contact-row-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.contact-row-edit {
  margin-top: 0.65rem;
}

/* ----- Timeline ----- */
.timeline { position: relative; padding-left: 1.25rem; }
.timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 0.25rem;
  bottom: 0.25rem;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding: 0 0 1.25rem 0.85rem;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.05rem;
  top: 0.35rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elevated);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.timeline-item .when {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.timeline-item .what {
  margin-top: 0.2rem;
  font-size: 0.875rem;
}

/* ----- Occupancy bars ----- */
.occ-bar {
  height: 8px;
  background: var(--bg-muted);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.4rem;
}
.occ-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #8a6d45);
  transition: width 0.6s var(--transition);
}
.occ-bar.high > span { background: linear-gradient(90deg, var(--warning), #a05a1a); }
.occ-bar.full > span { background: linear-gradient(90deg, var(--danger), #8a2020); }

/* ----- Grid helpers ----- */
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.muted { color: var(--text-secondary); }
.text-sm { font-size: 0.8rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}

/* ----- Login ----- */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--bg);
}

.login-hero {
  position: relative;
  background:
    linear-gradient(160deg, rgba(15,18,24,0.88), rgba(15,18,24,0.72)),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c4a574' fill-opacity='0.08'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"),
    #0f1218;
  color: #fff;
  padding: 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}

.login-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 30%, rgba(196,165,116,0.25), transparent),
    radial-gradient(ellipse 60% 40% at 80% 70%, rgba(61,126,166,0.2), transparent);
  pointer-events: none;
  animation: glowPulse 8s ease-in-out infinite alternate;
}

.login-hero-content { position: relative; z-index: 1; max-width: 420px; }

.login-logo {
  display: block;
  width: auto;
  max-width: 220px;
  height: 4.5rem;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 1.25rem;
}

.login-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 4vw, 3.4rem);
  font-weight: 400;
  margin: 0 0 0.75rem;
  line-height: 1.1;
}

.login-hero h1 em {
  font-style: italic;
  color: var(--accent);
}

.login-hero p {
  color: rgba(255,255,255,0.7);
  font-size: 1rem;
  margin: 0;
  max-width: 36ch;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-box {
  width: 100%;
  max-width: 400px;
  animation: riseIn 0.5s ease both;
}

.login-box h2 {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 400;
  margin: 0 0 0.35rem;
}

.login-box .subtitle {
  color: var(--text-secondary);
  margin-bottom: 1.75rem;
}

/* ----- Animations ----- */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes glowPulse {
  from { opacity: 0.7; }
  to   { opacity: 1; }
}

.kpi-card:nth-child(1) { animation-delay: 0.05s; }
.kpi-card:nth-child(2) { animation-delay: 0.1s; }
.kpi-card:nth-child(3) { animation-delay: 0.15s; }
.kpi-card:nth-child(4) { animation-delay: 0.2s; }

/* ----- Overlay mobile ----- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 35;
}
.sidebar-overlay.show { display: block; }

/* ----- Responsive ----- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { min-height: 220px; padding: 2rem; }
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
  .topbar { padding: 0 1rem; }
}
