:root {
      --bg: #080d14;
      --sidebar: #070a10;
      --panel: #101823;
      --panel-2: #0c131d;
      --panel-3: #151f2c;
      --text: #e6edf6;
      --muted: #91a1b5;
      --line: #223044;
      --brand: #29c6a6;
      --brand-2: #3b82f6;
      --danger: #f87171;
      --warning: #f6ad55;
      --ok: #34d399;
      --shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      min-height: 100vh;
      background: var(--bg);
      color: var(--text);
    }

    button,
    input,
    select,
    textarea {
      font: inherit;
    }

    button {
      min-height: 38px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #111a26;
      color: var(--text);
      padding: 0 12px;
      cursor: pointer;
    }

    button:hover:not(:disabled) {
      border-color: #3e526e;
      background: #172335;
    }

    button:disabled {
      cursor: not-allowed;
      opacity: 0.45;
    }

    button.primary {
      border-color: rgba(41, 198, 166, 0.8);
      background: var(--brand);
      color: #04110f;
      font-weight: 800;
    }

    button.danger {
      border-color: rgba(248, 113, 113, 0.45);
      color: var(--danger);
    }

    button.whatsapp-action {
      border-color: rgba(41, 198, 166, 0.55);
      background: rgba(41, 198, 166, 0.12);
      color: #8ff0dc;
      font-weight: 800;
    }

    button.whatsapp-action:hover:not(:disabled) {
      border-color: rgba(41, 198, 166, 0.85);
      background: rgba(41, 198, 166, 0.2);
    }

    button.whatsapp-action.small {
      min-height: 28px;
      padding: 0 9px;
      font-size: 12px;
    }

    .button-link {
      min-height: 38px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #111a26;
      color: var(--text);
      padding: 8px 12px;
      text-decoration: none;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-weight: 700;
    }

    .button-link:hover {
      border-color: #3e526e;
      background: #172335;
    }

    input,
    select,
    textarea {
      width: 100%;
      min-height: 40px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #0b121c;
      color: var(--text);
      padding: 9px 11px;
      outline: none;
    }

    input:focus,
    select:focus,
    textarea:focus {
      border-color: var(--brand);
      box-shadow: 0 0 0 3px rgba(41, 198, 166, 0.12);
    }

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

    .app {
      min-height: 100vh;
      display: grid;
      grid-template-columns: 244px minmax(0, 1fr);
    }

    .app.locked {
      display: none;
    }

    .auth-gate {
      min-height: 100vh;
      display: grid;
      place-items: center;
      padding: 24px;
      background:
        radial-gradient(circle at top left, rgba(41, 198, 166, 0.16), transparent 34%),
        radial-gradient(circle at bottom right, rgba(59, 130, 246, 0.14), transparent 30%),
        var(--bg);
    }

    .auth-card {
      width: min(440px, 100%);
      border: 1px solid var(--line);
      border-radius: 14px;
      background: var(--panel);
      box-shadow: var(--shadow);
      padding: 26px;
    }

    .auth-card .brand {
      padding: 0 0 18px;
      margin-bottom: 18px;
    }

    .auth-card h2 {
      margin: 0 0 8px;
      font-size: 24px;
    }

    .auth-card p {
      margin: 0 0 18px;
      color: var(--muted);
      line-height: 1.5;
    }

    .auth-message {
      min-height: 38px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel-2);
      color: var(--muted);
      padding: 10px 11px;
      font-size: 13px;
      margin-top: 14px;
    }

    .auth-message.denied {
      border-color: rgba(248, 113, 113, 0.5);
      color: #fecaca;
    }

    .denied-actions {
      display: grid;
      gap: 10px;
      margin-top: 14px;
    }

    .sidebar {
      position: sticky;
      top: 0;
      height: 100vh;
      display: grid;
      grid-template-rows: auto auto 1fr;
      align-content: start;
      gap: 14px;
      border-right: 1px solid var(--line);
      background: var(--sidebar);
      padding: 14px;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 2px 6px 12px;
      border-bottom: 1px solid var(--line);
    }

    .brand-mark {
      width: 40px;
      height: 40px;
      display: grid;
      place-items: center;
      border-radius: 10px;
      background: linear-gradient(135deg, var(--brand), var(--brand-2));
      color: #020617;
      font-weight: 900;
    }

    .brand h1 {
      margin: 0;
      font-size: 18px;
      line-height: 1.1;
    }

    .brand p {
      margin: 3px 0 0;
      color: var(--muted);
      font-size: 12px;
    }

    .nav {
      display: grid;
      align-content: start;
      gap: 8px;
    }

    .nav a {
      display: flex;
      align-items: center;
      gap: 10px;
      min-height: 42px;
      border-radius: 8px;
      padding: 0 12px;
      color: var(--muted);
      text-decoration: none;
    }

    .nav a.active,
    .nav a:hover {
      background: #111a26;
      color: var(--text);
    }

    .nav-dot {
      width: 8px;
      height: 8px;
      border-radius: 999px;
      background: var(--brand);
    }

    .save-state {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 8px;
      color: var(--muted);
      font-size: 13px;
      padding: 0 8px;
      align-self: end;
    }

    .save-dot {
      width: 8px;
      height: 8px;
      border-radius: 999px;
      background: var(--ok);
    }

    .save-dot.saving { background: var(--warning); }
    .save-dot.error { background: var(--danger); }

    .drive-connect {
      width: 100%;
      min-height: 34px;
      margin-top: 4px;
      border: 1px solid rgba(77, 163, 255, 0.45);
      background: rgba(77, 163, 255, 0.12);
      color: var(--text);
      border-radius: 8px;
      cursor: pointer;
      font-size: 13px;
    }

    .drive-connect:hover {
      border-color: rgba(77, 163, 255, 0.75);
      background: rgba(77, 163, 255, 0.18);
    }

    .main {
      min-width: 0;
      display: grid;
      grid-template-rows: auto 1fr;
    }

    .topbar {
      position: sticky;
      top: 0;
      z-index: 5;
      display: grid;
      grid-template-columns: minmax(190px, 0.6fr) minmax(480px, 1fr) minmax(220px, 280px);
      align-items: center;
      gap: 10px;
      min-height: 64px;
      border-bottom: 1px solid var(--line);
      background: rgba(8, 13, 20, 0.9);
      backdrop-filter: blur(12px);
      padding: 9px 18px;
    }

    .page-title {
      min-width: 0;
      overflow: visible;
    }

    .page-title h2 {
      margin: 0;
      font-size: 20px;
      line-height: 1.15;
    }

    .page-title p {
      margin: 3px 0 0;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.2;
      white-space: nowrap;
    }

    .top-actions {
      display: flex;
      flex-wrap: nowrap;
      justify-content: flex-start;
      gap: 6px;
      overflow: visible;
      white-space: nowrap;
      min-width: 0;
    }

    .top-actions button {
      flex: 0 0 auto;
      min-height: 32px;
      padding: 0 8px;
      font-size: 12px;
      line-height: 1;
    }

    .user-card {
      display: grid;
      grid-template-columns: 30px minmax(90px, 1fr) auto;
      align-items: center;
      gap: 7px;
      min-width: 0;
      justify-self: end;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel-2);
      padding: 5px;
    }

    .user-card img {
      width: 30px;
      height: 30px;
      border-radius: 999px;
      object-fit: cover;
      background: var(--panel-3);
    }

    .user-card strong,
    .user-card span {
      display: block;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .user-card strong {
      font-size: 12px;
    }

    .user-card span {
      color: var(--muted);
      font-size: 11px;
    }

    .user-card button {
      min-height: 30px;
      padding: 0 8px;
      font-size: 12px;
    }

    .content {
      min-width: 0;
      display: grid;
      gap: 18px;
      padding: 22px;
    }

    .stats {
      display: grid;
      grid-template-columns: repeat(5, minmax(150px, 1fr));
      gap: 14px;
    }

    .stat-card,
    .panel {
      border: 1px solid var(--line);
      border-radius: 10px;
      background: var(--panel);
      box-shadow: var(--shadow);
    }

    .stat-card {
      min-height: 106px;
      display: grid;
      align-content: space-between;
      padding: 16px;
    }

    .stat-card span {
      color: var(--muted);
      font-size: 13px;
    }

    .stat-card strong {
      font-size: 30px;
      line-height: 1;
    }

    .stat-card.total { border-color: rgba(59, 130, 246, 0.45); }
    .stat-card.today { border-color: rgba(41, 198, 166, 0.45); }
    .stat-card.overdue { border-color: rgba(248, 113, 113, 0.45); }
    .stat-card.closed { border-color: rgba(52, 211, 153, 0.45); }
    .stat-card.new { border-color: rgba(246, 173, 85, 0.45); }

    .dashboard-grid {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(320px, 0.78fr);
      gap: 18px;
    }

    .workspace-grid {
      display: grid;
      grid-template-columns: minmax(330px, 420px) minmax(0, 1fr);
      gap: 18px;
      align-items: start;
    }

    .panel-body {
      padding: 16px;
    }

    .panel-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 12px;
    }

    .panel-head h3 {
      margin: 0;
      font-size: 15px;
    }

    .panel-head span,
    .muted,
    .empty,
    .meta {
      color: var(--muted);
      font-size: 12px;
    }

    .table-list,
    .stack {
      display: grid;
      gap: 10px;
    }

    .mini-row,
    .customer-row,
    .list-item {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel-2);
    }

    .mini-row {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 10px;
      padding: 11px;
    }

    .mini-row strong,
    .customer-row strong {
      display: block;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .customer-tools {
      display: grid;
      gap: 10px;
      margin-bottom: 12px;
    }

    .search-row,
    .filter-row {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 8px;
    }

    .customer-list {
      max-height: 680px;
      overflow: auto;
      display: grid;
      align-content: start;
      gap: 8px;
    }

    .customer-row {
      min-height: 82px;
      width: 100%;
      display: grid;
      gap: 7px;
      text-align: left;
      padding: 11px;
      cursor: pointer;
    }

    .customer-row.active {
      border-color: var(--brand);
      box-shadow: 0 0 0 3px rgba(41, 198, 166, 0.12);
    }

    .row-main,
    .detail-header,
    .actions,
    .section-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
    }

    .actions {
      justify-content: flex-end;
      flex-wrap: wrap;
    }

    .chips {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }

    .chip {
      display: inline-flex;
      align-items: center;
      min-height: 23px;
      max-width: 100%;
      border-radius: 999px;
      padding: 3px 8px;
      background: #1a2635;
      color: #b7c5d8;
      font-size: 12px;
      font-weight: 700;
    }

    .chip.new { background: rgba(246, 173, 85, 0.16); color: #f8c37b; }
    .chip.active { background: rgba(52, 211, 153, 0.15); color: #7ee2b8; }
    .chip.inactive { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; }
    .chip.follow-up { background: rgba(59, 130, 246, 0.16); color: #93c5fd; }
    .chip.vip { background: rgba(192, 132, 252, 0.18); color: #d8b4fe; }
    .chip.problem { background: rgba(248, 113, 113, 0.16); color: #fca5a5; }
    .chip.closed { background: rgba(41, 198, 166, 0.16); color: #8af0db; }
    .chip.replied { background: rgba(41, 198, 166, 0.16); color: #8af0db; }
    .chip.no-reply { background: rgba(246, 173, 85, 0.16); color: #f8c37b; }
    .chip.blocked { background: rgba(248, 113, 113, 0.16); color: #fca5a5; }

    .detail {
      display: grid;
      gap: 16px;
    }

    .detail-title h3 {
      margin: 0 0 4px;
      font-size: 22px;
    }

    .detail-title p {
      margin: 0;
      color: var(--muted);
      font-size: 13px;
    }

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

    .field {
      display: grid;
      gap: 6px;
    }

    .field.full { grid-column: 1 / -1; }

    label,
    .label,
    .section-title {
      color: var(--muted);
      font-size: 12px;
      font-weight: 800;
    }

    .section-title {
      margin: 0;
      text-transform: uppercase;
      letter-spacing: 0;
    }

    .value {
      min-height: 40px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #0b121c;
      padding: 10px 11px;
      overflow-wrap: anywhere;
    }

    .inline-form {
      display: grid;
      grid-template-columns: 150px 1fr auto;
      gap: 8px;
      align-items: start;
    }

    .list-item {
      padding: 11px;
    }

    .list-item time {
      display: block;
      color: var(--muted);
      font-size: 12px;
      margin-bottom: 5px;
    }

    .todo-line {
      display: grid;
      grid-template-columns: auto 1fr auto;
      gap: 9px;
      align-items: start;
    }

    .todo-line input {
      width: 16px;
      min-height: 16px;
      margin-top: 4px;
    }

    .todo-line.done .todo-text {
      color: var(--muted);
      text-decoration: line-through;
    }

    .hidden,
    #restoreFile,
    #excelFile {
      display: none !important;
    }

    @media (max-width: 1120px) {
      .topbar {
        grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
      }
      .top-actions {
        grid-column: 1 / -1;
        grid-row: 2;
      }
      .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .dashboard-grid,
      .workspace-grid { grid-template-columns: 1fr; }
    }

    @media (max-width: 760px) {
      .app { grid-template-columns: 1fr; }
      .sidebar {
        position: relative;
        height: auto;
      }
      .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .topbar {
        position: relative;
        grid-template-columns: 1fr;
        align-items: stretch;
      }
      .top-actions { justify-content: flex-start; }
      .top-actions button { min-width: max-content; }
      .user-card { justify-self: stretch; }
      .user-card { grid-template-columns: 38px minmax(0, 1fr); }
      .user-card button { grid-column: 1 / -1; width: 100%; }
      .content { padding: 14px; }
      .stats { grid-template-columns: 1fr; }
      .grid,
      .inline-form,
      .search-row,
      .filter-row { grid-template-columns: 1fr; }
      .detail-header,
      .actions { align-items: flex-start; flex-direction: column; }
    }
