:root {
  --sidebar-bg: #1e2614;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active: linear-gradient(90deg, #4b6127 0%, #738c3a 100%);
  --sidebar-text: #eef3e4;
  --sidebar-muted: #a6b889;
  --bg-canvas: #f6f8f2;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5ea;
  --border: #dce4cd;
  --text-main: #1d2414;
  --text-muted: #5a6648;
  --heading: #273317;
  --primary: #556b2f;
  --primary-2: #6b8e23;
  --gradient-cta: linear-gradient(90deg, #4f6629 0%, #6d8c32 100%);
  --shadow-sm: 0 2px 10px rgba(39, 51, 23, 0.06);
  --shadow-md: 0 10px 30px rgba(39, 51, 23, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
}

body[data-theme="claro"] {
  --sidebar-bg: #ffffff;
  --sidebar-hover: #edf2e2;
  --sidebar-text: #273317;
  --sidebar-muted: #5e6b4a;
  --bg-canvas: #f8faf5;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5ea;
  --border: #dce4cd;
  --text-main: #1d2414;
  --text-muted: #5a6648;
  --heading: #273317;
}

body[data-theme="noturno"] {
  --sidebar-bg: #12170b;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-text: #edf2e3;
  --sidebar-muted: #a6b889;
  --bg-canvas: #171e0f;
  --bg-card: #222c17;
  --bg-subtle: #2b371e;
  --border: #3d4d2a;
  --text-main: #f2f6ea;
  --text-muted: #bac8a4;
  --heading: #ffffff;
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg-canvas); color: var(--text-main); }
button, input, select, textarea { font-family: inherit; }
a { color: var(--primary); text-decoration: none; }

/* Login Screen */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top left, #3c4d21 0%, #1e2614 55%, #12170b 100%);
}
.login-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  color: #1d2414;
  border-radius: 22px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand-badge {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--gradient-cta); color: #fff; font-weight: 800;
  display: grid; place-items: center; font-size: 13px; letter-spacing: 0.5px;
}
.login-tabs { display: flex; gap: 8px; background: #eff3e7; padding: 4px; border-radius: 12px; margin-bottom: 20px; }
.login-tab {
  flex: 1; padding: 10px; border: 0; background: transparent; border-radius: 9px;
  font-weight: 600; color: #5a6648; cursor: pointer;
}
.login-tab.active { background: #fff; color: #273317; box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
.demo-users { margin-top: 18px; padding-top: 16px; border-top: 1px dashed #dce4cd; }
.demo-user-chip {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 8px 12px; margin-top: 8px; border-radius: 10px;
  border: 1px solid #dce4cd; background: #f6f8f2; cursor: pointer; text-align: left;
  font-size: 13px; color: #1d2414;
}
.demo-user-chip:hover { border-color: #556b2f; background: #edf2e2; }

/* App Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 268px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; border-right: 1px solid rgba(255,255,255,0.08);
  transition: width 0.2s ease; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
body[data-theme="claro"] .sidebar { border-right: 1px solid var(--border); }
.sidebar.collapsed { width: 78px; }
.sidebar.collapsed .hide-collapsed { display: none; }

.sidebar-top { padding: 18px 16px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sidebar-logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; }
.sidebar-logo .accent { color: #a3b86c; }
.icon-btn {
  background: transparent; border: 1px solid rgba(255,255,255,0.14); color: inherit;
  border-radius: 10px; padding: 7px 10px; cursor: pointer; font-size: 13px;
}
body[data-theme="claro"] .sidebar .icon-btn { border-color: var(--border); }
.icon-btn:hover { background: var(--sidebar-hover); }

.nav-scroll { flex: 1; padding: 6px 12px 16px; }
.nav-group { margin-bottom: 12px; }
.nav-group-btn {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  background: transparent; border: 0; color: var(--sidebar-muted); font-size: 11px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; padding: 8px 10px; cursor: pointer;
}
.nav-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; margin-bottom: 3px; border: 0; border-radius: 11px;
  background: transparent; color: var(--sidebar-text); cursor: pointer; font-size: 13.5px; font-weight: 500; text-align: left;
}
.nav-item:hover { background: var(--sidebar-hover); }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; box-shadow: 0 6px 16px rgba(85, 107, 47, 0.30); }
body[data-theme="claro"] .nav-item.active { color: #fff; }
.nav-item-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nav-badge {
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: rgba(255,255,255,0.14); color: inherit;
}
body[data-theme="claro"] .nav-badge { background: #e8efe0; color: #3d5020; }
.nav-item.active .nav-badge { background: rgba(255,255,255,0.25); color: #fff; }

.sidebar-footer { padding: 12px 14px 16px; border-top: 1px solid rgba(255,255,255,0.08); }
body[data-theme="claro"] .sidebar-footer { border-top-color: var(--border); }
.theme-pills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: rgba(255,255,255,0.06); padding: 4px; border-radius: 10px; }
body[data-theme="claro"] .theme-pills { background: #eef3e6; }
.theme-pill {
  border: 0; background: transparent; color: var(--sidebar-text); font-size: 11px;
  font-weight: 600; padding: 6px 4px; border-radius: 7px; cursor: pointer;
}
.theme-pill.active { background: #556b2f; color: #fff; }

/* Main Column */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title { font-size: 16px; font-weight: 700; color: var(--heading); }
.topbar-sub { font-size: 13px; color: var(--text-muted); }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-subtle); color: var(--text-main); font-size: 13px; font-weight: 600; cursor: pointer;
}
.pill-btn:hover { border-color: var(--primary); }
.avatar-dot {
  width: 26px; height: 26px; border-radius: 999px; background: var(--gradient-cta);
  color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center;
}

.page-content { padding: 24px; max-width: 1420px; width: 100%; margin: 0 auto; }

/* Reusable Cards, Buttons, Forms */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
}
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title { font-size: 17px; font-weight: 700; color: var(--heading); margin: 0; }
.muted { color: var(--text-muted); font-size: 13.5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-main); font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--primary); }
.btn-primary {
  background: var(--gradient-cta); color: #fff; border: 0;
  box-shadow: 0 6px 16px rgba(85, 107, 47, 0.28);
}
.btn-primary:hover { opacity: 0.94; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-danger { background: #fef2f2; color: #dc2626; border-color: #fecaca; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: transform 0.15s ease, border-color 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.kpi-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.kpi-label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--heading); margin: 6px 0 4px; }
.kpi-sub { font-size: 12px; color: var(--text-muted); }

.tabs-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab-pill {
  padding: 8px 15px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-muted); font-size: 13px; font-weight: 600; cursor: pointer;
}
.tab-pill.active { background: var(--gradient-cta); color: #fff; border-color: transparent; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--heading); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-subtle); color: var(--text-main); font-size: 14px; outline: none;
}
.input:focus { border-color: var(--primary); background: var(--bg-card); }
textarea.input { min-height: 90px; resize: vertical; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: #e9f0dc; color: #3d5020;
}
.badge-pink { background: #dce7c7; color: #2d3d14; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* Kanban Pipeline */
.kanban-board {
  display: flex; gap: 14px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start;
}
.kanban-col {
  min-width: 270px; width: 270px; flex-shrink: 0;
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 14px; padding: 12px;
}
.kanban-col.drag-over { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(85, 107, 47, 0.25); }
.kanban-col-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 13px; font-weight: 700; color: var(--heading); }
.kanban-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; margin-bottom: 10px; cursor: grab; box-shadow: var(--shadow-sm);
}
.kanban-card:hover { border-color: var(--primary-2); }
.kanban-card-title { font-weight: 700; font-size: 14px; color: var(--heading); margin-bottom: 4px; }

/* Table */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th, table.data-table td {
  padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle;
}
table.data-table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); }

/* Progress */
.progress-track { height: 9px; border-radius: 999px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--gradient-cta); transition: width 0.25s ease; }

/* Phone Story Mockup */
.phone-frame {
  width: 270px; margin: 0 auto; border-radius: 30px; padding: 14px;
  background: #171e0f; color: #fff; border: 4px solid #4b6127; box-shadow: var(--shadow-md);
}
.phone-bars { display: flex; gap: 4px; margin-bottom: 12px; }
.phone-bar { flex: 1; height: 3px; border-radius: 99px; background: rgba(255,255,255,0.28); }
.phone-bar.active { background: #fff; }
.phone-screen {
  min-height: 330px; border-radius: 18px; padding: 18px;
  background: linear-gradient(160deg, #2d3d14 0%, #6b8e23 100%);
  display: flex; flex-direction: column; justify-content: space-between;
}

/* Modal & Toast */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(18, 23, 11, 0.65); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: var(--bg-card); color: var(--text-main); border: 1px solid var(--border);
  border-radius: 20px; width: 100%; max-width: 720px; max-height: 90vh;
  display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1e2614; color: #fff; padding: 12px 16px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; box-shadow: 0 10px 26px rgba(0,0,0,0.3); border-left: 4px solid #84a93c;
}

.banner-hero {
  background: linear-gradient(120deg, #273317 0%, #556b2f 100%); color: #fff;
  border-radius: var(--radius); padding: 22px 24px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
}
.contract-preview {
  background: #ffffff; color: #111827; border: 1px solid #d1d5db; border-radius: 12px;
  padding: 28px; font-size: 13.5px; line-height: 1.65; max-height: 620px; overflow-y: auto;
}

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .page-content { padding: 0 !important; }
  .contract-preview { max-height: none !important; border: 0 !important; box-shadow: none !important; }
}
@media (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; box-shadow: 10px 0 32px rgba(0,0,0,0.45); max-width: 84vw; }
  .sidebar.collapsed { width: 0; overflow: hidden; border: 0; box-shadow: none; }
}

@media (max-width: 640px) {
  html, body, .app-shell, .main-col { max-width: 100vw; overflow-x: hidden; }
  .topbar { position: relative; padding: 10px 14px; flex-direction: column; align-items: stretch; gap: 8px; }
  .topbar-left { width: 100%; gap: 10px; }
  .topbar-title { font-size: 15px; line-height: 1.2; }
  .topbar-sub { font-size: 11.5px; }
  .topbar-right {
    width: 100%; display: flex; flex-wrap: nowrap; align-items: center;
    justify-content: flex-end; gap: 6px;
  }
  .topbar-right .pill-btn { padding: 6px 9px; font-size: 11.5px; flex-shrink: 0; white-space: nowrap; }
  .topbar-right select.pill-btn {
    flex: 1 1 auto; min-width: 0; max-width: 100%;
    text-overflow: ellipsis; overflow: hidden; padding: 6px 8px;
  }
  .topbar-right button.pill-btn span:nth-child(2) { display: none; }
  .topbar-right button.pill-btn:has(.avatar-dot) { padding: 4px; }
  .avatar-dot { width: 24px; height: 24px; font-size: 10px; }

  .page-content { padding: 14px; }
  .banner-hero { padding: 16px; border-radius: 14px; flex-direction: column; align-items: flex-start; gap: 12px; }
  .banner-hero h2 { font-size: 20px !important; }
  .card { padding: 14px; border-radius: 14px; }
  .card-header { flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
  .card-title { font-size: 16px; }

  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi-card { padding: 13px; border-radius: 14px; }
  .kpi-label { font-size: 11.5px; }
  .kpi-value { font-size: 21px; }
  .kpi-sub { font-size: 11px; }

  .tabs-row {
    display: flex; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    gap: 6px; padding-bottom: 6px; margin-bottom: 12px;
  }
  .tab-pill { white-space: nowrap; flex-shrink: 0; padding: 7px 12px; font-size: 12.5px; }

  .kanban-col { min-width: 82vw; width: 82vw; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table.data-table th, table.data-table td { padding: 9px 8px; font-size: 12.5px; }

  .modal-backdrop { padding: 10px; }
  .modal-box { max-height: 92vh; border-radius: 16px; }
  .modal-head, .modal-body, .modal-foot { padding: 14px; }
  .modal-foot { flex-wrap: wrap; }

  .login-page { padding: 14px; }
  .login-card { padding: 22px 18px; border-radius: 18px; }
  .toast-root { left: 14px; right: 14px; bottom: 14px; }
}
