:root {
  --bg: #0b0d10;
  --panel: #11151a;
  --panel-2: #171c22;
  --border: #2a3139;
  --text: #f5f7fa;
  --muted: #9da7b3;
  --gold: #d6b46a;
  --gold-2: #f0d28c;
  --danger: #ff7a7a;
  --success: #73d4a2;
  --shadow: 0 24px 80px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.eyebrow { margin: 0 0 4px; font-size: 11px; letter-spacing: .18em; color: var(--gold); font-weight: 800; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 10% 10%, rgba(214,180,106,.12), transparent 32%),
    radial-gradient(circle at 90% 0%, rgba(255,255,255,.05), transparent 28%),
    var(--bg);
}

.auth-card {
  width: min(440px, 100%);
  background: rgba(17,21,26,.96);
  border: 1px solid var(--border);
  padding: 32px;
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--gold-2), #9d7435);
  color: #0d0d0d; font-weight: 900;
}
.auth-card h1, .topbar h2, .dialog-head h3 { margin: 0; }

.stack { display: grid; gap: 14px; margin-top: 24px; }
label { display: grid; gap: 7px; color: #dfe5ec; font-size: 13px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: #0c1014;
  color: var(--text);
  border-radius: 12px;
  padding: 12px 13px;
  outline: none;
  transition: .2s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(214,180,106,.12); }

.btn {
  border: 0; border-radius: 12px; padding: 11px 15px;
  cursor: pointer; font-weight: 800;
}
.btn-primary { background: linear-gradient(145deg, var(--gold-2), #b78d48); color: #101010; }
.btn-ghost { background: #1b2128; color: var(--text); border: 1px solid var(--border); }
.icon-btn { border: 0; background: transparent; color: var(--muted); font-size: 28px; cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid var(--border);
  background: #0e1115;
  padding: 22px 16px;
  display: flex; flex-direction: column;
}
.sidebar-brand { padding: 4px 7px 24px; }
.nav { display: grid; gap: 7px; }
.nav-item {
  text-align: left; padding: 12px 14px; border: 0; border-radius: 12px;
  background: transparent; color: var(--muted); cursor: pointer; font-weight: 750;
}
.nav-item.active, .nav-item:hover { background: #171c22; color: var(--text); }
.sidebar-bottom { margin-top: auto; display: grid; gap: 10px; }

.content { padding: 30px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 24px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px,1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}
.stat-card span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.stat-card strong { display: block; font-size: clamp(19px, 2vw, 27px); }
.stat-card small { color: #6f7b87; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
}
.toolbar {
  display: grid;
  grid-template-columns: minmax(240px,1fr) 160px 160px 155px auto;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1050px; }
th, td { padding: 14px 15px; border-bottom: 1px solid #20262d; font-size: 13px; white-space: nowrap; }
th { text-align: left; color: #8d98a5; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; background: #0f1317; }
td.right { font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 40px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge-open { background: rgba(255,180,88,.12); color: #ffc06d; }
.badge-paid { background: rgba(115,212,162,.12); color: var(--success); }
.badge-overdue { background: rgba(255,122,122,.12); color: var(--danger); }
.link-btn { background: none; border: 0; color: var(--gold-2); font-weight: 800; cursor: pointer; padding: 0; }
.status-select { padding: 7px 9px; min-width: 105px; }

dialog {
  width: min(760px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 0;
}
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(4px); }
.dialog-card { padding: 22px; }
.dialog-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span-2 { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.form-message { min-height: 18px; color: var(--danger); font-size: 12px; }

.toast {
  position: fixed; z-index: 100;
  right: 18px; top: 18px;
  max-width: 360px;
  background: #171c22; color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 14px; border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transform: translateY(-8px);
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar-bottom { margin-top: 18px; }
  .content { padding: 18px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .stats-grid, .toolbar, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}


/* Invoice Hub V1.3 */
.table-wrap {
  overflow-x: auto;
  scrollbar-gutter: stable;
}
table {
  min-width: 980px;
}
th, td {
  padding-left: 12px;
  padding-right: 12px;
}
.actions-col {
  min-width: 150px;
}
.row-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}
.table-action {
  border: 1px solid var(--border);
  background: #171c22;
  color: var(--text);
  border-radius: 9px;
  padding: 7px 9px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  transition: .18s ease;
}
.table-action:hover {
  border-color: #596675;
  background: #202730;
}
.table-action-doc {
  color: var(--gold-2);
  border-color: rgba(214,180,106,.28);
}
.table-action-danger {
  color: #ff9a9a;
}
.btn-danger {
  background: #8e2f35;
  color: #fff;
  border: 1px solid #ad444b;
}
.btn-danger:hover {
  background: #a63840;
}
.current-file-info {
  color: var(--gold-2);
  font-weight: 650;
}
.confirm-dialog {
  width: min(460px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 0;
}
.confirm-dialog::backdrop {
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(4px);
}
.confirm-card {
  padding: 24px;
}
.confirm-card h3 {
  margin: 0 0 10px;
}
@media (min-width: 1200px) {
  .content {
    padding-left: 24px;
    padding-right: 24px;
  }
  .stats-grid {
    gap: 10px;
  }
  .stat-card {
    padding: 16px;
  }
}
@media (max-width: 900px) {
  table {
    min-width: 900px;
  }
}
