/* Opsenia Business. No inline styles anywhere: everything is a class here. */
:root {
  --ink: #1b2230;
  --soft: #5d6677;
  --faint: #8b93a3;
  --line: #e2e5eb;
  --bg: #f5f6f8;
  --card: #ffffff;
  --brand: #153d63;
  --brand-2: #1f5288;
  --brand-tint: #e7eef6;
  --navy: #14284b;
  --navy-2: #1b3560;
  --gold: #c9a45c;
  --gold-soft: #e3c98f;
  --serif: Georgia, "Times New Roman", serif;
  --good: #1e7a4d;
  --good-tint: #e5f4ec;
  --warn: #9a5b00;
  --warn-tint: #fdf2df;
  --bad: #b3261e;
  --bad-tint: #fbe9e7;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--brand-2); }
h1 { font-family: var(--serif); font-size: 1.65rem; margin: 0 0 4px; color: var(--navy); }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: 0.95rem; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--soft); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* ---------- Layout ---------- */
.app { min-height: 100%; }
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, var(--navy), var(--navy-2)); color: #dbe5f0; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; color: #fff; }
.brand-mark { width: 38px; height: 36px; flex: none; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 1.25rem; line-height: 1.1; }
.brand small { display: block; font-family: var(--font); font-weight: 400; color: var(--gold-soft); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; }
.nav a { display: block; padding: 8px 12px; border-radius: 8px; color: #dbe5f0; text-decoration: none; }
.nav a:hover { background: rgba(255,255,255,0.07); }
.nav a.active { background: rgba(255,255,255,0.12); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--gold); }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,0.1); font-size: 0.85rem; color: #9fb3c8; }
.sidebar-foot a { color: #dbe5f0; }
.main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.menu-btn { display: none; }

@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 30% 0 0; z-index: 20; transform: translateX(-105%); transition: transform 0.2s; }
  .sidebar.open { transform: none; }
  .main { padding: 16px 14px 60px; }
  .menu-btn { display: inline-flex; margin-bottom: 12px; }
}

/* ---------- Cards and grids ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--soft); font-size: 0.82rem; }
.stat .value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .sub { color: var(--faint); font-size: 0.8rem; }
.stat.attention { border-color: #f0c98a; background: var(--warn-tint); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--soft); font-weight: 600; }
tbody tr:hover { background: #fafbfc; }
tfoot td { font-weight: 700; border-bottom: none; }
td.actions { white-space: nowrap; text-align: right; }
.empty { color: var(--faint); padding: 18px 4px; }
tr.inactive td { color: var(--faint); }

/* ---------- Forms ---------- */
form.stack { display: grid; gap: 12px; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 0.84rem; font-weight: 600; color: var(--soft); }
.field .hint { font-size: 0.78rem; color: var(--faint); }
.check { flex-direction: row; align-items: center; gap: 8px; }
input, select, textarea {
  font: inherit; color: inherit; padding: 8px 10px; border: 1px solid #cdd2da; border-radius: 8px; background: #fff; width: 100%;
}
input[type=checkbox] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: var(--brand-2); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.filters .field { min-width: 150px; }

/* ---------- Buttons ---------- */
button, .btn {
  font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; text-decoration: none;
  background: var(--brand); color: #fff; line-height: 1.3;
}
button:hover, .btn:hover { background: var(--brand-2); }
button:disabled { opacity: 0.55; cursor: default; }
.btn-light { background: #fff; color: var(--ink); border-color: #cdd2da; }
.btn-light:hover { background: #f1f3f6; }
.btn-danger { background: #fff; color: var(--bad); border-color: #e7b9b5; }
.btn-danger:hover { background: var(--bad-tint); }
.btn-small { padding: 4px 10px; font-size: 0.83rem; }
.link-btn { background: none; border: none; color: var(--brand-2); padding: 0 4px; font-weight: 600; }
.link-btn:hover { background: none; text-decoration: underline; }

/* ---------- Badges and messages ---------- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; background: #eef0f3; color: var(--soft); }
.badge.draft { background: #eef0f3; color: var(--soft); }
.badge.sent { background: var(--brand-tint); color: var(--brand); }
.badge.paid { background: var(--good-tint); color: var(--good); }
.badge.overdue { background: var(--bad-tint); color: var(--bad); }
.badge.warn { background: var(--warn-tint); color: var(--warn); }
.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.notice.error { background: var(--bad-tint); color: var(--bad); }
.notice.ok { background: var(--good-tint); color: var(--good); }
.notice.info { background: var(--brand-tint); color: var(--brand); }
.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 50; padding: 10px 16px; border-radius: 8px;
  background: var(--ink); color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,0.18);
}
.toast.error { background: var(--bad); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { background: none; color: var(--soft); border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 12px; }
.tabs button:hover { background: none; color: var(--ink); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- Dialog ---------- */
dialog { border: none; border-radius: 12px; padding: 22px; width: min(640px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
dialog::backdrop { background: rgba(20, 30, 45, 0.45); }

/* ---------- Sign-in ---------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 20%, var(--navy-2), var(--navy) 70%); }
.signin .card { border-top: 3px solid var(--gold); }
.signin .card { width: min(420px, 100%); padding: 28px; }
.signin .brand { color: var(--navy); padding: 0 0 16px; }
.signin .brand small { color: #9a7a3c; }
.qr { display: block; margin: 8px auto; width: 200px; height: 200px; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--bg); padding: 8px; border-radius: 6px; text-align: center; letter-spacing: 0.05em; word-break: break-all; }
.code-input { font-size: 1.4rem; letter-spacing: 0.3em; text-align: center; }

/* ---------- Folders ---------- */
.folders { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.folders button { background: #fff; color: var(--ink); border-color: #cdd2da; }
.folders button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.lines td { padding: 6px 10px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; }
.kv dt { color: var(--soft); }
.kv dd { margin: 0; }
.pre { white-space: pre-line; }
.logo-preview { display: block; max-width: 240px; max-height: 90px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 6px; background: #fff; }
