/* ─────────────────────────────────────────────────────────────────────────────
   Nexus Suite — shared design system
   Loaded by the launcher and by both apps, so the three surfaces stay visually
   identical. App-specific rules go in that page's own <style> block.
   ───────────────────────────────────────────────────────────────────────────── */

  /* ── Design Tokens ─────────────────────────────── */
  :root {
    --bg: #0a0b0f;
    --surface: #111318;
    --surface-2: #181b22;
    --surface-3: #1e2230;
    --border: rgba(255,255,255,0.07);
    --border-bright: rgba(255,255,255,0.14);
    --text: #e8eaf0;
    --text-muted: #6b7280;
    --text-dim: #9ca3af;
    --accent: #3b82f6;
    --accent-dim: rgba(59,130,246,0.15);
    --accent-glow: rgba(59,130,246,0.3);
    --green: #10b981;
    --green-dim: rgba(16,185,129,0.12);
    --red: #ef4444;
    --red-dim: rgba(239,68,68,0.12);
    --yellow: #f59e0b;
    --yellow-dim: rgba(245,158,11,0.12);
    --radius: 10px;
    --radius-sm: 6px;
    --mono: 'DM Mono', monospace;
    --sans: 'DM Sans', sans-serif;
    --display: 'Syne', sans-serif;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
  }

  /* Scrollbar */
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

  /* ── Layout ──────────────────────────────────────── */
  #app { display: flex; height: 100vh; overflow: hidden; }

  .sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow-y: auto;
  }

  .sidebar-logo {
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--border);
  }

  .logo-mark {
    font-family: var(--display);
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text);
  }
  .logo-mark span { color: var(--accent); }

  .logo-sub {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 2px;
  }

  .nav-section {
    padding: 16px 12px 8px;
  }

  .nav-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 8px;
    margin-bottom: 6px;
  }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-dim);
    font-size: 13.5px;
    font-weight: 400;
    transition: all 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
  }
  .nav-item:hover { background: var(--surface-2); color: var(--text); }
  .nav-item.active { background: var(--accent-dim); color: var(--accent); }
  .nav-item.active .nav-icon { color: var(--accent); }

  .nav-icon { font-size: 15px; opacity: 0.8; flex-shrink: 0; }

  .nav-badge {
    margin-left: auto;
    background: var(--surface-3);
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
  }
  .nav-item.active .nav-badge { background: var(--accent-dim); color: var(--accent); }

  .sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid var(--border);
  }

  .user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
  }

  .user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600; color: white;
    flex-shrink: 0;
  }

  .user-name { font-size: 12.5px; font-weight: 500; color: var(--text); }
  .user-role { font-size: 11px; color: var(--text-muted); }

  /* ── Main Content ─────────────────────────────────── */
  .main {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }

  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .page-title {
    font-family: var(--display);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
  }

  .topbar-actions { display: flex; gap: 10px; align-items: center; }

  /* ── Content Area ─────────────────────────────────── */
  .content { padding: 28px; flex: 1; }

  /* ── Cards ───────────────────────────────────────── */
  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
  }

  .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
  }

  .card-title {
    font-family: var(--display);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.2px;
  }

  /* ── Stats Row ───────────────────────────────────── */
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
  }

  .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
  }

  .stat-label { font-size: 11px; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); }
  .stat-value {
    font-family: var(--display);
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -1px;
    margin-top: 4px;
    color: var(--text);
  }
  .stat-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
  .stat-accent { color: var(--accent); }
  .stat-green { color: var(--green); }
  .stat-yellow { color: var(--yellow); }

  /* ── Buttons ─────────────────────────────────────── */
  .btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
  }

  .btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
  }
  .btn-primary:hover { background: #2563eb; box-shadow: 0 0 20px var(--accent-glow); }

  .btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border-color: var(--border-bright);
  }
  .btn-ghost:hover { background: var(--surface-2); color: var(--text); }

  .btn-danger {
    background: var(--red-dim);
    color: var(--red);
    border-color: rgba(239,68,68,0.2);
  }
  .btn-danger:hover { background: rgba(239,68,68,0.2); }

  .btn-success {
    background: var(--green-dim);
    color: var(--green);
    border-color: rgba(16,185,129,0.2);
  }
  .btn-success:hover { background: rgba(16,185,129,0.2); }

  .btn-sm { padding: 5px 12px; font-size: 12px; }
  .btn-xs { padding: 3px 8px; font-size: 11px; }

  /* ── Forms ───────────────────────────────────────── */
  .form-group { margin-bottom: 14px; }
  .form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
  }

  .form-input, .form-select, .form-textarea {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    color: var(--text);
    font-family: var(--sans);
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s;
    -webkit-appearance: none;
  }
  .form-input:focus, .form-select:focus { border-color: var(--accent); }
  .form-input.mono { font-family: var(--mono); font-size: 13px; letter-spacing: 0.5px; }
  .form-input.error { border-color: var(--red); }
  .form-error { color: var(--red); font-size: 11.5px; margin-top: 4px; }

  .form-select option { background: var(--surface-2); }

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

  table {
    width: 100%;
    border-collapse: collapse;
  }

  thead th {
    text-align: left;
    padding: 9px 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
  }

  tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
  }
  tbody tr:hover { background: var(--surface-2); }
  tbody tr:last-child { border-bottom: none; }

  tbody td {
    padding: 11px 12px;
    font-size: 13px;
    color: var(--text-dim);
  }
  tbody td.bold { color: var(--text); font-weight: 500; }
  tbody td.mono { font-family: var(--mono); font-size: 12px; letter-spacing: 0.3px; }

  /* ── Badges / Status ─────────────────────────────── */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
  }
  .badge-draft { background: var(--surface-3); color: var(--text-muted); }
  .badge-generated { background: var(--green-dim); color: var(--green); }
  .badge-submitted { background: var(--accent-dim); color: var(--accent); }

  /* ── Modal ───────────────────────────────────────── */
  .modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.15s ease;
  }

  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
  @keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

  .modal {
    background: var(--surface);
    border: 1px solid var(--border-bright);
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease;
  }

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

  .modal-title {
    font-family: var(--display);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
  }

  .modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 18px;
    padding: 4px;
    transition: color 0.1s;
    line-height: 1;
  }
  .modal-close:hover { color: var(--text); }

  .modal-body { padding: 20px 24px; }
  .modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
  }

  /* ── Grid layouts ─────────────────────────────────── */
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
  .grid-cols-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }

  /* ── Upload Zone ─────────────────────────────────── */
  .upload-zone {
    border: 2px dashed var(--border-bright);
    border-radius: var(--radius);
    padding: 36px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
  }
  .upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-dim);
  }
  .upload-icon { font-size: 32px; margin-bottom: 10px; }
  .upload-text { font-size: 14px; font-weight: 500; color: var(--text); }
  .upload-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

  /* ── Tabs ─────────────────────────────────────────── */
  .tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
  .tab {
    padding: 10px 18px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
  }
  .tab:hover { color: var(--text); }
  .tab.active { color: var(--accent); border-bottom-color: var(--accent); }

  /* ── Empty State ─────────────────────────────────── */
  .empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
  }
  .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
  .empty-title { font-size: 15px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
  .empty-sub { font-size: 13px; }

  /* ── Toast ───────────────────────────────────────── */
  .toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border-bright);
    font-size: 13px;
    font-weight: 500;
    min-width: 280px;
    animation: slideUp 0.2s ease;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  }
  .toast-success { background: var(--surface-2); border-color: rgba(16,185,129,0.3); color: var(--green); }
  .toast-error { background: var(--surface-2); border-color: rgba(239,68,68,0.3); color: var(--red); }
  .toast-info { background: var(--surface-2); border-color: rgba(59,130,246,0.3); color: var(--accent); }

  /* ── Misc ─────────────────────────────────────────── */
  .divider { height: 1px; background: var(--border); margin: 20px 0; }
  .flex { display: flex; }
  .flex-col { flex-direction: column; }
  .gap-2 { gap: 8px; }
  .gap-3 { gap: 12px; }
  .gap-4 { gap: 16px; }
  .items-center { align-items: center; }
  .justify-between { justify-content: space-between; }
  .ml-auto { margin-left: auto; }
  .text-right { text-align: right; }
  .mt-1 { margin-top: 4px; }
  .mt-2 { margin-top: 8px; }
  .mt-3 { margin-top: 12px; }
  .mb-3 { margin-bottom: 12px; }
  .mb-4 { margin-bottom: 16px; }
  .font-mono { font-family: var(--mono); font-size: 12px; letter-spacing: 0.3px; }
  .text-accent { color: var(--accent); }
  .text-green { color: var(--green); }
  .text-red { color: var(--red); }
  .text-muted { color: var(--text-muted); }
  .text-sm { font-size: 12px; }
  .fw-600 { font-weight: 600; }
  .amount-cell { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--text); text-align: right; }

  /* Login */
  .login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
  }
  .login-card {
    background: var(--surface);
    border: 1px solid var(--border-bright);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
  }
  .login-title {
    font-family: var(--display);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
  }
  .login-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }

  /* Spinner */
  .spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* Amount display */
  .amount-big {
    font-family: var(--mono);
    font-size: 28px;
    font-weight: 400;
    letter-spacing: -1px;
    color: var(--text);
  }
  .currency-symbol { color: var(--text-muted); font-size: 16px; margin-right: 3px; }

  .section-title {
    font-family: var(--display);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.4px;
    margin-bottom: 18px;
  }

  .info-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }
  .info-row:last-child { border-bottom: none; }
  .info-key { font-size: 12px; color: var(--text-muted); min-width: 90px; }
  .info-val { font-size: 13px; color: var(--text); }
  .info-val.mono { font-family: var(--mono); font-size: 12px; letter-spacing: 0.3px; }

  /* Alert */
  .alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
  }
  .alert-warning { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(245,158,11,0.2); }
  .alert-info { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(59,130,246,0.2); }

  .batch-row-detail {
    background: var(--surface-2);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
  }

  /* ── E-Invoice additions ─────────────────────────────────────────────────── */
  .badge-issued    { background: rgba(139,92,246,0.12); color: #8b5cf6; }
  .badge-sent      { background: var(--accent-dim); color: var(--accent); }
  .badge-paid      { background: var(--green-dim); color: var(--green); }
  .badge-cancelled { background: var(--red-dim); color: var(--red); }

  .vat-chip { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 4px; font-size: 11px; font-family: var(--mono); background: var(--surface-3); color: var(--text-dim); }
  .invoice-totals-box { background: var(--surface-2); border-radius: var(--radius); padding: 14px 18px; }
  .total-row { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 0; font-size: 13px; }
  .total-row.grand { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; }
  .total-row.grand .total-label { font-weight: 600; color: var(--text); font-size: 14px; }
  .total-row.grand .total-val { font-family: var(--mono); font-size: 18px; font-weight: 500; color: var(--text); }
  .total-label { color: var(--text-muted); }
  .total-val { font-family: var(--mono); color: var(--text-dim); }
  .format-card { border: 1px solid var(--border-bright); border-radius: var(--radius); padding: 12px 16px; cursor: pointer; transition: all 0.15s; }
  .format-card:hover { border-color: var(--accent); background: var(--accent-dim); }
  .format-card.selected { border-color: var(--accent); background: var(--accent-dim); }
  .format-flag { font-size: 22px; }

  /* ── Additions for the merged suite ─────────────────────────────────────── */
  /* Helper text under an input — used for password rules and XML field notes. */
  .form-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 5px;
    line-height: 1.45;
  }

  /* A labelled rule that groups related fields inside a long form. */
  .section-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 22px 0 14px;
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
  }
  .section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
  }

  /* Sidebar control that returns to the launcher. */
  .nav-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    margin-bottom: 4px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease, background .15s ease;
  }
  .nav-switch:hover {
    color: var(--text);
    border-color: var(--border-bright);
    background: var(--surface-2);
  }
