:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 10px 30px rgba(2, 8, 23, 0.08);

  --primary: #2563eb;
  --primary-700: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --neutral: #475569;

  --radius: 12px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.45;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

.container {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
}

.page {
  padding: 22px 0 40px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

.h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.muted {
  color: var(--muted);
}

.small { font-size: 13px; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.stack {
  display: grid;
  gap: 14px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 820px) {
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: stretch; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(2, 8, 23, 0.03);
}

.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-body { padding: 16px; }

.kpi {
  padding: 14px 16px;
}

.kpi .label {
  font-size: 13px;
  color: var(--muted);
}

.kpi .value {
  margin-top: 6px;
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.topnav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.topnav__inner {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--text);
}

.brand-badge {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
}

.topnav__links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topnav__link {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  color: #0f172a;
  font-size: 13px;
  text-decoration: none;
}

.topnav__link:hover {
  text-decoration: none;
  background: #f1f5f9;
}
  
  /* Invoice frame + corners (print styling) */
  .invoice-frame {
    position: relative;
    border: 2px solid #d9b76b;
    padding: 16px;
  }
  .invoice-corner {
    position: absolute;
    width: 18px;
    height: 18px;
  }
  .invoice-corner::before,
  .invoice-corner::after {
    content: '';
    position: absolute;
    background: #d9b76b;
  }
  .invoice-corner.tl { left: 10px; top: 10px; }
  .invoice-corner.tl::before { width: 2px; height: 14px; left: 0; top: 0; }
  .invoice-corner.tl::after  { width: 14px; height: 2px; left: 0; top: 0; }
  .invoice-corner.tr { right: 10px; top: 10px; }
  .invoice-corner.tr::before { width: 2px; height: 14px; right: 0; top: 0; }
  .invoice-corner.tr::after  { width: 14px; height: 2px; right: 0; top: 0; }
  .invoice-corner.bl { left: 10px; bottom: 10px; }
  .invoice-corner.bl::before { width: 2px; height: 14px; left: 0; bottom: 0; }
  .invoice-corner.bl::after  { width: 14px; height: 2px; left: 0; bottom: 0; }
  .invoice-corner.br { right: 10px; bottom: 10px; }
  .invoice-corner.br::before { width: 2px; height: 14px; right: 0; bottom: 0; }
  .invoice-corner.br::after  { width: 14px; height: 2px; right: 0; bottom: 0; }
  
  .table-header-gold {
    background: #f6efe0;
  }

.user-chip {
  font-size: 12px;
  color: var(--muted);
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-700); }

.btn-outline {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: #f8fafc;
}

.btn-danger {
  background: #fff;
  border-color: #fecaca;
  color: var(--danger);
}

.btn-danger:hover {
  background: #fef2f2;
}

.btn-link {
  background: transparent;
  border-color: transparent;
  color: var(--primary);
  padding: 0;
  height: auto;
}

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--muted);
  font-weight: 700;
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.table tr:hover td { background: #fbfdff; }

.text-right { text-align: right !important; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
}

.badge-paid { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.badge-unpaid { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.badge-cancelled { background: #f1f5f9; color: #334155; border-color: var(--border); }

.form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.label {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}

.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
  background: #fff;
}

.textarea { resize: vertical; min-height: 92px; }

.input:focus, .select:focus, .textarea:focus {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.help {
  font-size: 12px;
  color: var(--muted);
}

.alert {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid;
  font-size: 13px;
}

.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

.auth {
  min-height: calc(100vh - 54px);
  display: grid;
  place-items: center;
  padding: 24px 0;
}

.auth-card {
  width: min(440px, calc(100% - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.auth-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.auth-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

@media print {
  .topnav, .no-print { display: none !important; }
  body { background: white; }
  .card { box-shadow: none; }
  a { text-decoration: none; color: inherit; }
  /* Keep two-column layouts in print to avoid stacking */
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
