/* HexoProxy owner panel. No external assets: system Persian-capable fonts only. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1c2230;
  --muted: #667085;
  --border: #e1e4ea;
  --accent: #2458d6;
  --accent-hover: #1d49b5;
  --accent-text: #ffffff;
  --ok: #157f3c;
  --ok-bg: #e5f5eb;
  --warn: #9a5b00;
  --warn-bg: #fdf1dc;
  --err: #b42318;
  --err-bg: #fdeceb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1a1e26;
    --surface-2: #232834;
    --text: #e6e9ef;
    --muted: #98a2b3;
    --border: #2d3340;
    --accent: #5b8cff;
    --accent-hover: #769fff;
    --accent-text: #0d1321;
    --ok: #5fd08a;
    --ok-bg: #173323;
    --warn: #f0b551;
    --warn-bg: #3a2c12;
    --err: #ff8a80;
    --err-bg: #3d1a19;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Vazirmatn, Vazir, "Segoe UI", Tahoma, "Noto Sans Arabic", "DejaVu Sans", sans-serif;
  font-size: 15px;
  line-height: 1.7;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: .4rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.8rem 0 .7rem; }
h1 small, h2 small { font-size: .8rem; font-weight: normal; }
code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  font-size: .86em;
  background: var(--surface-2);
  padding: .05em .35em;
  border-radius: 5px;
  unicode-bidi: isolate;
  direction: ltr;
}
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.error-text { color: var(--err); overflow-wrap: anywhere; }
.empty { color: var(--muted); text-align: center; padding: 1.2rem; }

/* header */
.top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.top-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: .5rem 16px;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.brand { font-weight: bold; color: var(--text); font-size: 1.05rem; white-space: nowrap; }
.top nav {
  display: flex;
  gap: .2rem;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}
.top nav a {
  color: var(--muted);
  padding: .35rem .7rem;
  border-radius: 8px;
  white-space: nowrap;
}
.top nav a:hover { background: var(--surface-2); text-decoration: none; }
.top nav a.active { color: var(--text); background: var(--surface-2); font-weight: bold; }
.logout { display: flex; align-items: center; gap: .5rem; margin: 0; white-space: nowrap; }
.count {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 .4em;
  border-radius: 999px;
  background: var(--err);
  color: #fff;
  font-size: .75rem;
  text-align: center;
  line-height: 1.5;
  font-weight: bold;
}

main { max-width: 1280px; margin: 0 auto; padding: 1rem 16px 3rem; }
main.narrow { max-width: 440px; padding-top: 12vh; }

/* flash */
.flash {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash.err { background: var(--err-bg); color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, transparent); }

/* surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.card h1:first-child, .card h2:first-child { margin-top: 0; }
details.card > summary { cursor: pointer; font-weight: bold; }
details.card[open] > summary { margin-bottom: .6rem; }
.login h1 { font-size: 1.25rem; }
.crumbs { margin: 0; font-size: .9rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem .9rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
  color: var(--text);
  box-shadow: var(--shadow);
}
a.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat b { font-size: 1.3rem; }
.stat b.small { font-size: 1rem; }
.stat.attention { border-color: var(--warn); background: var(--warn-bg); }
.stat.bad { border-color: var(--err); background: var(--err-bg); }

/* tables */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .75rem; text-align: start; vertical-align: top; border-bottom: 1px solid var(--border); }
th { font-size: .82rem; color: var(--muted); font-weight: normal; background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.dim td { opacity: .6; }
code.link {
  display: block;
  max-width: 24rem;
  min-width: 12rem;
  overflow-wrap: anywhere;
  user-select: all;
  -webkit-user-select: all;
  text-align: left;
  font-size: .75rem;
  cursor: copy;
}
.usage .bar-cell { width: 55%; vertical-align: middle; }
.bar, .meter { background: var(--surface-2); border-radius: 999px; height: .55rem; overflow: hidden; }
.bar span, .meter span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter { height: .7rem; margin: -.25rem 0 1rem; }

/* badges */
.badge {
  display: inline-block;
  padding: .05rem .55rem;
  border-radius: 999px;
  font-size: .8rem;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
  vertical-align: middle;
}
.badge.ok, .badge.active, .badge.approved { background: var(--ok-bg); color: var(--ok); }
.badge.limited, .badge.pending_review, .badge.awaiting_receipt { background: var(--warn-bg); color: var(--warn); }
.badge.err, .badge.disabled, .badge.rejected, .badge.deleted { background: var(--err-bg); color: var(--err); }

/* forms */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .45rem .65rem;
  min-height: 2.4rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
textarea { resize: vertical; font-family: ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", monospace; font-size: .9rem; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
label > input, label > select, label > textarea { color: var(--text); }
.code-input { font-size: 1.5rem; letter-spacing: .4em; text-align: center; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .9rem; align-items: end; }
.grid .wide, .grid .form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin: 0 0 .9rem; }
.toolbar input, .toolbar select { width: auto; flex: 1 1 180px; }
.inline-form { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; margin: 0; }
.inline-form label { flex: 1 1 160px; }
.actions-row { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: end; }
.actions-row .inline-form { flex: 1 1 260px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  min-height: 2.4rem;
  padding: .35rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--border)); }
.btn.danger:hover { background: var(--err-bg); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 2rem; padding: .2rem .7rem; font-size: .85rem; }

/* invoices */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.invoice header { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; margin-bottom: .5rem; }
.invoice dl { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; margin: 0 0 .8rem; font-size: .92rem; }
.invoice dt { color: var(--muted); }
.invoice dd { margin: 0; }
.receipt { display: block; margin-bottom: .8rem; }
.receipt img {
  display: block;
  width: 100%;
  max-height: 380px;
  object-fit: contain;
  background: var(--surface-2);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.decide { display: flex; flex-direction: column; gap: .6rem; }

@media (max-width: 720px) {
  body { font-size: 14px; }
  .top-inner { flex-wrap: wrap; gap: .3rem .8rem; }
  .top nav { order: 3; flex-basis: 100%; }
  .logout { margin-inline-start: auto; }
  .logout .muted { display: none; }
  main.narrow { padding-top: 6vh; }
  .stat b { font-size: 1.15rem; }
}
