/* Shared styles for admin + portal panels */
@font-face {
  font-family: 'Aller Display';
  src: url('fonts/AllerDisplay.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #0e1524;
  --ink-muted: #6b7a94;
  --line: #e4e8f1;
  --accent: #1CADE4;
  --accent2: #0E8BC2;
  --warn: #e76e50;
  --ok: #3dbb7f;
  --danger: #dc2c4a;
  --side: #101a2d;
  --side-ink: #cfd9ec;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.panel, body.login-page {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink); min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: #1877d2; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: 'DM Sans', system-ui, sans-serif; letter-spacing: -.01em; }

/* ---------- Login ---------- */
body.login-page {
  display: grid; place-items: center; padding: 40px 20px; min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255,255,255,0.35), transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(28,173,228,0.22), transparent 55%),
    linear-gradient(180deg, #00A8E0 0%, #19C2F2 55%, #9BE1F6 100%);
  color: #0B2B3A;
  position: relative; overflow: hidden;
}
body.login-page::before {
  content: ''; position: absolute; inset: -5%; z-index: 0;
  background:
    radial-gradient(60% 40% at 15% 30%, rgba(255,255,255,0.45), transparent 60%),
    radial-gradient(55% 35% at 80% 65%, rgba(255,255,255,0.35), transparent 60%),
    radial-gradient(45% 30% at 45% 80%, rgba(255,255,255,0.30), transparent 60%);
  filter: blur(24px);
  pointer-events: none;
}
/* Floating decorative rings */
body.login-page::after {
  content: ''; position: absolute; bottom: -80px; right: -80px;
  width: 340px; height: 340px; border-radius: 50%; z-index: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.22) 0%, transparent 70%);
  pointer-events: none;
}
.login-card {
  position: relative; z-index: 2;
  background: rgba(255,255,255,0.93);
  border: 1px solid rgba(255,255,255,0.75);
  padding: 44px 38px 36px;
  border-radius: 24px;
  max-width: 420px; width: 100%;
  backdrop-filter: saturate(200%) blur(20px);
  -webkit-backdrop-filter: saturate(200%) blur(20px);
  box-shadow:
    0 32px 80px rgba(11, 43, 58, 0.26),
    0 2px 8px rgba(11, 43, 58, 0.10),
    inset 0 1px 0 rgba(255,255,255,0.8);
  color: #0B2B3A;
}
.login-card .brand {
  display: flex; align-items: center; justify-content: center;
  gap: 11px;
  margin: 0 0 6px;
  color: #0E8BC2;
}
.login-card .brand .login-mark {
  width: 42px; height: 42px;
  color: #1CADE4;
  flex: 0 0 auto;
  filter: drop-shadow(0 2px 6px rgba(28,173,228,0.35));
}
.login-card .brand .brand-mark {
  font-family: 'Aller Display', 'DM Sans', system-ui, sans-serif;
  font-weight: 400;
  font-size: 40px;
  letter-spacing: -0.02em;
  line-height: 1;
  text-transform: lowercase;
  background: linear-gradient(90deg, #1CADE4 0%, #0E8BC2 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-card .muted {
  color: #3d5f70; font-size: 13px; margin: 0 0 28px;
  letter-spacing: 0.06em; text-transform: uppercase;
  text-align: center;
}
/* 4-box PIN entry */
.login-card .pin-entry {
  display: flex; gap: 10px;
  justify-content: center;
  margin-top: 4px;
}
.login-card .pin-box {
  width: 56px; height: 64px;
  padding: 0;
  text-align: center;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0;
  color: #0B2B3A;
  background: #fff;
  border: 1.5px solid #d7e3ee;
  border-radius: 12px;
  caret-color: #1CADE4;
  transition: border-color .15s, box-shadow .15s, transform .12s;
  -moz-appearance: textfield;
}
.login-card .pin-box::-webkit-outer-spin-button,
.login-card .pin-box::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.login-card .pin-box:focus {
  outline: 0;
  border-color: #1CADE4;
  box-shadow: 0 0 0 4px rgba(28,173,228,0.18);
  transform: translateY(-1px);
}
.login-card .pin-box.filled {
  border-color: #1CADE4;
  background: #f2fbff;
}
.login-card label.pin-label { text-align: center; }
.login-card label.pin-label span { text-align: center; }
/* Login — mobile responsive */
@media (max-width: 520px) {
  body.login-page { padding: 20px 16px; align-items: flex-start; padding-top: 48px; }
  .login-card {
    padding: 36px 26px 30px;
    border-radius: 20px;
    max-width: 100%;
  }
  .login-card .brand .login-mark { width: 36px; height: 36px; }
  .login-card .brand .brand-mark { font-size: 34px; }
  .login-card .muted { font-size: 12px; margin-bottom: 22px; }
}
@media (max-width: 400px) {
  body.login-page { padding: 16px 12px; padding-top: 32px; }
  .login-card { padding: 30px 20px 26px; border-radius: 16px; }
  .login-card .brand .login-mark { width: 32px; height: 32px; }
  .login-card .brand .brand-mark { font-size: 30px; }
  .login-card .pin-entry { gap: 8px; }
  .login-card .pin-box { width: 50px; height: 58px; font-size: 24px; }
  .login-card .btn-primary { padding: 13px 18px; }
}
.login-card label {
  display: block; margin-bottom: 14px; font-size: 12px;
  color: #3d5f70; font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.login-card label span { display: block; margin-bottom: 6px; }
.login-card input {
  width: 100%; padding: 13px 14px;
  background: #fff;
  border: 1.5px solid #d7e3ee;
  border-radius: 10px;
  color: #0B2B3A;
  font: inherit; font-size: 15px; font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus {
  outline: 0;
  border-color: #1CADE4;
  box-shadow: 0 0 0 4px rgba(28,173,228,0.18);
}
.login-card input::placeholder { color: #9fb0c0; }
.login-card .btn-primary {
  width: 100%; margin-top: 14px;
  padding: 14px 22px; font-size: 15px;
  background: linear-gradient(90deg, #1CADE4 0%, #0E8BC2 100%);
  color: #fff;
  border: 0; border-radius: 999px;
  font-weight: 700; letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(28,173,228,0.35);
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
}
.login-card .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(28,173,228,0.45);
  filter: brightness(1.05);
  text-decoration: none;
}
.login-card .btn-primary:active { transform: translateY(0); }
.login-card .flash {
  padding: 11px 14px; border-radius: 10px; margin: 0 0 18px;
  font-size: 13px; font-weight: 500;
}
.login-card .flash-err {
  background: rgba(255, 99, 99, 0.12);
  border: 1px solid rgba(220, 44, 74, 0.35);
  color: #a4162e;
}
.login-alt {
  margin: 22px 0 0; font-size: 12px; text-align: center;
  color: #3d5f70; letter-spacing: 0.02em;
}
.login-alt a { color: #0E8BC2; font-weight: 600; }
.login-alt a:hover { color: #1CADE4; text-decoration: none; }

/* ---------- Layout ---------- */
body.panel { display: flex; }
.side {
  width: 240px; min-width: 240px; background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
}
.side .brand {
  padding: 4px 8px 20px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.side .brand a {
  display: flex; align-items: center; gap: 10px;
  color: #fff; text-decoration: none;
  transition: opacity .2s;
}
.side .brand a:hover { opacity: .85; text-decoration: none; }
.side .side-mark {
  width: 30px; height: 30px; color: var(--accent);
  flex: 0 0 auto;
  filter: drop-shadow(0 1px 4px rgba(28,173,228,0.5));
}
.side .brand .brand-mark {
  font-family: 'Aller Display', 'DM Sans', system-ui, sans-serif;
  font-weight: 400;
  font-size: 27px;
  letter-spacing: -0.02em;
  line-height: 1;
  text-transform: lowercase;
  background: linear-gradient(90deg, #fff 0%, rgba(255,255,255,0.82) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.side .who { padding: 12px 8px; font-size: 13px; }
.side .who strong { display: block; color: #fff; }
.side .who .muted { color: #8598bc; font-size: 11px; }
.side nav { display: flex; flex-direction: column; gap: 2px; padding-top: 12px; flex: 1; }
.side nav a {
  padding: 10px 12px; color: var(--side-ink); border-radius: 8px; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.side nav a:hover { background: rgba(255,255,255,.05); text-decoration: none; }
.side nav a.on { background: linear-gradient(90deg, rgba(34,211,238,.22), rgba(28,173,228,.18)); color: #fff; }
.badge { background: var(--warn); color: #fff; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.side-foot { padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; display: flex; justify-content: space-between; align-items: center; }
.side-foot a { color: var(--side-ink); }
.lang-switch a { margin-right: 4px; }

.main { flex: 1; min-width: 0; }
.main-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px 30px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.main-head h1 { margin: 0; font-size: 20px; font-weight: 600; }
.menu-toggle { display: none; background: 0; border: 0; font-size: 20px; cursor: pointer; color: var(--ink); }
.main-body { padding: 24px 30px 60px; max-width: 1400px; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: 8px; margin: 0 0 16px; font-size: 14px; border: 1px solid; }
.flash-ok { background: #e8f7ee; border-color: #8fd6a8; color: #1b4f2b; }
.flash-err { background: #fde5e7; border-color: #f1a4ad; color: #7a1422; }

/* ---------- Cards / stats ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.stat .lbl { font-size: 12px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .num { display: block; margin-top: 6px; font-size: 24px; font-weight: 600; }
.stat .num small { font-size: 13px; color: var(--ink-muted); font-weight: 400; }

/* ---------- Panel blocks ---------- */
.panel-block {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 24px; margin-bottom: 20px;
}
.panel-block h2 { margin: 0 0 14px; font-size: 16px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 960px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; padding: 8px 10px; font-weight: 600; color: var(--ink-muted); border-bottom: 1px solid var(--line); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.row-unread td:first-child { border-left: 3px solid var(--warn); }
.tbl tr:hover { background: #fafbfe; }
.muted { color: var(--ink-muted); font-size: 12px; }

/* ---------- Pills ---------- */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #eef2f8; color: var(--ink-muted); text-transform: uppercase; }
.pill-open, .pill-unpaid { background: #fde5e7; color: #a51b37; }
.pill-replied, .pill-paid { background: #e4f6ec; color: #1b6f39; }
.pill-awaiting_user { background: #fef3dc; color: #7a5410; }
.pill-closed, .pill-cancelled { background: #e8ebf2; color: var(--ink-muted); }
.pill-external { background: linear-gradient(90deg, rgba(34,211,238,.2), rgba(28,173,228,.2)); color: #0E8BC2; }

/* External-hosted file viewer */
.viewer-external { padding: 16px; background: #f7faff; border: 1px solid var(--line); border-radius: 10px; }
.viewer-external .viewer-iframe { width: 100%; height: 520px; border: 0; border-radius: 8px; margin: 12px 0; background: #000; }

/* ---------- Forms ---------- */
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-form label { display: grid; gap: 5px; font-size: 12px; color: var(--ink-muted); font-weight: 500; }
.grid-form label span { font-weight: 500; }
.grid-form .full { grid-column: 1 / -1; }
.grid-form input, .grid-form textarea, .grid-form select {
  padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); font: inherit; width: 100%;
}
.grid-form input:focus, .grid-form textarea:focus, .grid-form select:focus {
  outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,211,238,.15);
}
.grid-form textarea { resize: vertical; min-height: 80px; font-family: inherit; }
.grid-form .check { display: flex; align-items: center; gap: 8px; flex-direction: row; }
.grid-form .check input { width: auto; }
@media (max-width: 720px) { .grid-form { grid-template-columns: 1fr; } }

.btn-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.btn-primary, .btn-ghost, .btn-danger {
  display: inline-block; padding: 10px 18px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer; font-size: 14px; font-family: inherit; text-decoration: none;
}
.btn-primary { background: linear-gradient(90deg, var(--accent), var(--accent2)); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); text-decoration: none; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: #f0f2f7; text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-link { color: var(--accent); font-size: 13px; font-weight: 500; }
.btn-link-danger { background: 0; border: 0; color: var(--danger); font: inherit; cursor: pointer; padding: 0 4px; font-size: 12px; }

/* ---------- Misc ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filters { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.filters a { padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--ink-muted); }
.filters a.on { background: var(--ink); color: #fff; }
.filters a:hover { text-decoration: none; }

.add-form summary { cursor: pointer; font-weight: 600; padding: 6px 0; color: var(--accent); }
.add-form[open] summary { margin-bottom: 14px; }

/* Tickets thread */
.thread { display: flex; flex-direction: column; gap: 12px; margin: 18px 0; }
.msg { padding: 14px 16px; border-radius: 10px; border: 1px solid var(--line); background: #fafbfe; }
.msg-admin { background: #eef8fc; border-color: #c6e6f2; }
.msg-head { font-size: 12px; margin-bottom: 6px; }
.msg-body { white-space: pre-wrap; word-wrap: break-word; font-size: 14px; line-height: 1.55; }
.ticket-reply { display: grid; gap: 8px; }
.ticket-reply label { display: grid; gap: 6px; font-size: 12px; color: var(--ink-muted); font-weight: 500; }
.ticket-reply textarea { padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px; font: inherit; min-height: 120px; resize: vertical; }
.ticket-reply textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,211,238,.15); }

/* Sparkline */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding: 8px 0; }
.spark .bar { flex: 1; background: linear-gradient(180deg, var(--accent), var(--accent2)); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.spark .bar em { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--ink-muted); font-style: normal; }

/* Invoice big */
.big-amount { font-size: 32px; font-weight: 600; margin: 14px 0; }

/* Gateway cards */
.gw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 14px 0; }
.gw-card { background: #fafbfe; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.gw-card h4 { margin: 0 0 8px; font-size: 14px; }
.gw-card code { background: #fff; padding: 2px 6px; border-radius: 4px; font-size: 12px; word-break: break-all; }

/* Gateways (admin) */
.gw { background: #fafbfe; border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; margin-bottom: 10px; }
.gw summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding: 4px 0; list-style: none; }
.gw summary::-webkit-details-marker { display: none; }
.gw-key { font-weight: 600; }
.gw-key code { background: #fff; padding: 1px 6px; border-radius: 4px; font-size: 11px; color: var(--ink-muted); margin-left: 6px; }
.gw[open] { padding-bottom: 14px; }

/* Uploader */
#uploader input[type=file] {
  padding: 10px; background: #fafbfe; border: 2px dashed var(--line); border-radius: 10px; width: 100%;
  font: inherit;
}
.up-row { display: grid; grid-template-columns: 1fr 200px 120px; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; font-size: 13px; background: #fafbfe; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-bar { background: #e4e8f1; height: 6px; border-radius: 999px; overflow: hidden; }
.up-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); width: 0%; transition: width .2s; }
.up-status { color: var(--ink-muted); font-size: 12px; }
.up-err .up-status { color: var(--danger); }

/* Viewer */
.viewer { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.viewer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.viewer-head h2 { margin: 0; font-size: 16px; }
.viewer-img { max-width: 100%; height: auto; border-radius: 6px; }
.viewer-video, .viewer-audio { width: 100%; border-radius: 6px; }
.viewer-iframe { width: 100%; height: 80vh; border: 1px solid var(--line); border-radius: 6px; }
.viewer-text { white-space: pre-wrap; word-wrap: break-word; background: #0e1524; color: #e9f2ff; padding: 16px; border-radius: 6px; font-size: 12px; max-height: 70vh; overflow: auto; }
.viewer-zip ul { max-height: 400px; overflow: auto; font-size: 13px; }

/* Mobile panel */
@media (max-width: 800px) {
  body.panel { flex-direction: column; }
  .side {
    position: fixed; top: 0; left: 0; width: 270px; height: 100vh;
    transform: translateX(-100%); transition: transform .28s cubic-bezier(.4,0,.2,1);
    z-index: 90; box-shadow: 4px 0 32px rgba(0,0,0,0.3);
  }
  .side.open { transform: none; }
  /* Dark overlay when sidebar is open */
  .side-overlay {
    display: none; position: fixed; inset: 0; z-index: 80;
    background: rgba(0,0,0,0.45); backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  .side.open ~ .side-overlay,
  body.panel:has(.side.open) .side-overlay { display: block; }
  .main-head {
    padding: 14px 18px; position: sticky; top: 0; z-index: 50;
    background: var(--surface); border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
  }
  .menu-toggle { display: block; }
  .main-body { padding: 16px 18px 80px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .filters { overflow-x: auto; white-space: nowrap; border-radius: 8px; }
  .up-row { grid-template-columns: 1fr; gap: 6px; }
  .tbl { font-size: 13px; }
  .tbl th, .tbl td { padding: 8px 8px; }
  .two-col { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, 1fr); }
}
