:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #111827;
  --muted: #5b6472;
  --line: #d9dee7;
  --brand: #b91c1c;
  --brand-dark: #881111;
  --ok: #166534;
  --warn: #92400e;
  --bad: #991b1b;
  --focus: #2563eb;
}

* { box-sizing: border-box; }
html { font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
body { margin: 0; min-height: 100vh; }
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus, button:focus, input:focus, select:focus, textarea:focus { outline: 3px solid rgba(37, 99, 235, .35); outline-offset: 2px; }

.topbar { background: #111827; color: #fff; border-bottom: 4px solid var(--brand); }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 14px 18px; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 800; font-size: 20px; letter-spacing: 0; }
.nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.nav a { color: #fff; padding: 8px 10px; border-radius: 6px; }
.nav a.active, .nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; }

.container { max-width: 1180px; margin: 0 auto; padding: 24px 18px 48px; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 18px; flex-wrap: wrap; }
h1 { margin: 0; color: var(--brand); font-size: 30px; }
h2 { margin: 24px 0 12px; font-size: 20px; }
.muted { color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; box-shadow: 0 1px 2px rgba(15,23,42,.06); margin-bottom: 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { border-left: 4px solid var(--brand); }
.stat-value { font-size: 30px; font-weight: 800; margin-top: 8px; }

label { display: block; font-weight: 700; margin: 0 0 6px; }
input, select, textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 6px; padding: 10px 11px; font: inherit; background: #fff; }
textarea { resize: vertical; }
.field { margin-bottom: 14px; }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline input[type="checkbox"], .inline input[type="radio"] { width: auto; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.btn, button { border: 0; border-radius: 6px; padding: 10px 14px; font: inherit; font-weight: 700; cursor: pointer; background: #e5e7eb; color: #111827; display: inline-flex; gap: 8px; align-items: center; justify-content: center; }
.btn:hover, button:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-secondary { background: #374151; color: #fff; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-link { background: transparent; padding: 0; color: #1d4ed8; font-weight: 700; }
.btn-small { padding: 6px 9px; font-size: 14px; }

.alert { padding: 12px 14px; border-radius: 8px; margin: 0 0 16px; border: 1px solid; background: #fff; }
.alert-success { color: var(--ok); border-color: #86efac; background: #f0fdf4; }
.alert-error { color: var(--bad); border-color: #fecaca; background: #fef2f2; }
.alert-warning { color: var(--warn); border-color: #fcd34d; background: #fffbeb; }
.alert-info { color: #1e3a8a; border-color: #bfdbfe; background: #eff6ff; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f8fafc; color: #374151; font-size: 14px; }
tr:last-child td { border-bottom: 0; }
.status { display: inline-block; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 800; background: #e5e7eb; }
.status-cancelled { background: #fee2e2; color: #991b1b; }
.status-issued { background: #dcfce7; color: #166534; }
.empty { text-align: center; color: var(--muted); padding: 32px; }
.pdf-frame { width: 100%; min-height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.items-row { display: grid; grid-template-columns: 1.4fr 1.4fr .6fr .5fr auto; gap: 10px; align-items: end; margin-bottom: 10px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tabs a { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--text); }
.tabs a.active { background: #111827; color: #fff; border-color: #111827; text-decoration: none; }

@media (max-width: 760px) {
  .topbar-inner { align-items: flex-start; }
  .nav { width: 100%; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .items-row { grid-template-columns: 1fr; border: 1px solid var(--line); padding: 12px; border-radius: 8px; }
  h1 { font-size: 24px; }
}
