:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #0177B6;
  --accent-hover: #015a8c;
  --accent-soft: rgba(1, 119, 182, 0.12);
  --success: #166534;
  --success-soft: #dcfce7;
  --danger: #991b1b;
  --danger-soft: #fee2e2;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: "DM Sans", system-ui, sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; }

.guest-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; background: linear-gradient(160deg, var(--bg) 0%, var(--accent-soft) 50%, var(--bg) 100%); }
.guest-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 2rem; box-shadow: 0 12px 40px rgba(2, 8, 23, 0.08); }
.guest-brand { margin-bottom: 1.5rem; text-align: center; }
.guest-brand img { height: 48px; margin: 0 auto; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: var(--surface); border-right: 1px solid var(--border); padding: 1.5rem 0; display: flex; flex-direction: column; }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem 1.5rem; color: var(--accent); font-weight: 700; }
.sidebar-brand img { height: 40px; }
.sidebar-nav { display: flex; flex-direction: column; gap: .25rem; }
.sidebar-nav a { padding: .75rem 1.25rem; color: var(--text-muted); }
.sidebar-nav a.active, .sidebar-nav a:hover { background: var(--accent-soft); color: var(--accent); }
.sidebar-user { margin-top: auto; padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: .5rem; color: var(--text-muted); }
.app-main { flex: 1; padding: 2rem 2.5rem; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.page-header h1 { margin: 0; font-size: 1.6rem; }

.card, .table-wrap, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.table-wrap { padding: 0; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .95rem 1.15rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { background: var(--surface-hover); color: var(--text-muted); font-size: .92rem; }
.table tr:last-child td { border-bottom: 0; }
.muted { color: var(--text-muted); }

.form-grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label { color: var(--text-muted); font-size: .92rem; font-weight: 600; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem .9rem; background: var(--bg); }
.field textarea { min-height: 88px; resize: vertical; }
.field-readonly input { background: var(--surface-hover); }
.section-title { margin: 0 0 .25rem; font-size: 1.05rem; }
.section-note { margin: 0 0 1rem; color: var(--text-muted); }

.btn-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.btn, .btn-secondary, .btn-link, .btn-danger { border: 0; border-radius: 10px; padding: .72rem 1rem; cursor: pointer; font-weight: 600; }
.btn { background: var(--accent); color: #fff; }
.btn:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-hover); color: var(--text); border: 1px solid var(--border); }
.btn-link { background: transparent; color: var(--accent); padding: 0; }
.btn-danger { background: var(--danger); color: #fff; }
.inline-form { display: inline-flex; }

.alert { padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; }
.alert.success { background: var(--success-soft); color: var(--success); }
.alert.error { background: var(--danger-soft); color: var(--danger); }

.invoice-items { display: grid; gap: .75rem; margin: 1rem 0; }
.invoice-item-row { display: grid; grid-template-columns: minmax(0, 2fr) 90px 120px 140px auto; gap: .75rem; align-items: start; }
.invoice-items-head { display: grid; grid-template-columns: minmax(0, 2fr) 90px 120px 140px auto; gap: .75rem; color: var(--text-muted); font-size: .86rem; font-weight: 700; }
.item-description { min-height: 84px; line-height: 1.45; }
.line-total { min-height: 48px; display: flex; align-items: center; justify-content: flex-end; padding: .75rem .9rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-hover); font-weight: 700; }
.invoice-summary { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; font-weight: 700; }
.stack { display: grid; gap: 1.25rem; }
.split-panels { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .85fr); gap: 1rem; align-items: start; }
.summary-list { display: grid; gap: .75rem; }
.summary-row { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: .75rem; border-bottom: 1px dashed var(--border); }
.summary-row:last-child { border-bottom: 0; padding-bottom: 0; }
.summary-row span:last-child { text-align: right; }
.status-badge { display: inline-block; padding: .25rem .6rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .84rem; }
.status-badge.paid { background: var(--success-soft); color: var(--success); }
.security-card { padding-top: 0; }
.setup-panel { border: 1px dashed var(--border); border-radius: var(--radius); padding: 1rem; background: var(--surface-hover); }

.pay-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; background: linear-gradient(160deg, var(--bg) 0%, var(--accent-soft) 50%, var(--bg) 100%); }
.pay-card { width: 100%; max-width: 520px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 2rem; }
.pay-logo { text-align: center; margin-bottom: 1.25rem; }
.pay-logo img { height: 44px; margin: 0 auto; }
.line-items { list-style: none; padding: 0; margin: 1rem 0; }
.line-items li { display: flex; justify-content: space-between; padding: .35rem 0; border-bottom: 1px dashed var(--border); }
.cards { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-top: 1rem; }
.cards img { height: 34px; width: auto; }

@media (max-width: 860px) {
  .app-shell { display: block; }
  .sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--border); }
  .app-main { padding: 1rem; }
  .grid-2, .grid-3, .invoice-item-row, .invoice-items-head, .split-panels { grid-template-columns: 1fr; }
}
