/* ==========================================================================
   Hintonn AI Networking — application stylesheet
   Brand tokens are defined once here and used everywhere. No hard-coded
   hex values outside this block, so re-theming is a single edit.
   ========================================================================== */

:root {
  /* Brand */
  --navy:        #0F172A;
  --primary:     #2563EB;
  --primary-dim: #1D4FD8;
  --violet:      #9333EA;
  --sky:         #1683FF;
  --grad:        linear-gradient(135deg, #1683FF 0%, #2563EB 55%, #9333EA 100%);

  /* Text */
  --text:        #334155;
  --text-strong: #0F172A;
  --muted:       #64748B;
  --faint:       #94A3B8;

  /* Surfaces */
  --bg:          #F6F8FC;
  --card:        #FFFFFF;
  --line:        #E2E8F0;
  --line-soft:   #EEF2F7;
  --hover:       #F1F5FD;

  /* Status */
  --ok:          #16A34A;
  --ok-bg:       #DCFCE7;
  --warn:        #D97706;
  --warn-bg:     #FEF3C7;
  --danger:      #DC2626;
  --danger-bg:   #FEE2E2;
  --info-bg:     #DBEAFE;

  /* Shape */
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;
  --shadow:    0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.05);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.10);
  --ease: cubic-bezier(.4,0,.2,1);

  /* Layout */
  --nav-w: 232px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .brand, .stat-value, .btn {
  font-family: Manrope, Inter, -apple-system, sans-serif;
}

h1 { font-size: 1.65rem; font-weight: 800; color: var(--text-strong); margin: 0 0 .25rem; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; font-weight: 700; color: var(--text-strong); margin: 0 0 .75rem; }
h3 { font-size: 1rem;    font-weight: 700; color: var(--text-strong); margin: 0 0 .5rem; }
p  { margin: 0 0 .75rem; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted  { color: var(--muted); }
.faint  { color: var(--faint); }
.small  { font-size: .84rem; }
.mono   { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .82rem; }
.center { text-align: center; }
.right  { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.grow   { flex: 1 1 auto; }
.row    { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.col    { display: flex; flex-direction: column; gap: .6rem; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---------- shell ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--nav-w); flex: 0 0 var(--nav-w);
  background: var(--navy); color: #fff;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand {
  padding: 1.1rem 1.15rem; font-weight: 800; font-size: 1.02rem;
  letter-spacing: -.01em; display: flex; align-items: center; gap: .55rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--grad); flex: 0 0 9px;
}
.sidebar nav { padding: .7rem 0; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .58rem 1.15rem; color: rgba(255,255,255,.72);
  font-size: .885rem; font-weight: 500; text-decoration: none;
  border-left: 3px solid transparent; transition: background .15s var(--ease), color .15s var(--ease);
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar nav a.on { color: #fff; background: rgba(255,255,255,.09); border-left-color: var(--sky); }
.sidebar nav a .ico { width: 16px; text-align: center; opacity: .9; font-size: .95rem; }
.sidebar nav .grp {
  padding: .9rem 1.15rem .35rem; font-size: .68rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.36);
}
.sidebar .who {
  border-top: 1px solid rgba(255,255,255,.08); padding: .85rem 1.15rem;
  font-size: .8rem; color: rgba(255,255,255,.6);
}
.sidebar .who .em { color: #fff; display: block; margin-bottom: .15rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .who button { color: rgba(255,255,255,.6); }

.main { flex: 1; min-width: 0; padding: 1.6rem 1.9rem 3rem; }
.page-head { margin-bottom: 1.3rem; }
.page-head .sub { color: var(--muted); font-size: .9rem; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 1.25rem; box-shadow: var(--shadow);
  margin-bottom: 1.1rem;
}
.card.tight { padding: .9rem 1rem; }
.card-flush { padding: 0; overflow: hidden; }
.card-head {
  padding: .85rem 1.1rem; border-bottom: 1px solid var(--line-soft);
  font-weight: 700; color: var(--text-strong); font-size: .95rem;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
}
.card-body { padding: 1.1rem; }

.grid { display: grid; gap: 1rem; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* ---------- stats ---------- */
.stat { display: flex; flex-direction: column; gap: .15rem; }
.stat-label { font-size: .72rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--text-strong); line-height: 1.15; }
.stat-sub   { font-size: .8rem; color: var(--faint); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .58rem 1.05rem; border-radius: var(--r); border: 1px solid transparent;
  background: var(--primary); color: #fff; font-size: .89rem; font-weight: 600;
  cursor: pointer; transition: background .15s var(--ease), transform .08s var(--ease);
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--primary-dim); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.grad { background: var(--grad); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text-strong); }
.btn.ghost:hover:not(:disabled) { background: var(--hover); }
.btn.danger { background: var(--danger); }
.btn.ok { background: var(--ok); }
.btn.sm { padding: .38rem .7rem; font-size: .8rem; }
.btn.wide { width: 100%; }
button.link { background: none; border: 0; color: var(--primary); cursor: pointer;
  font: inherit; padding: 0; }

/* ---------- forms ---------- */
label.f { display: block; margin-bottom: .85rem; }
label.f > span.lbl {
  display: block; font-size: .8rem; font-weight: 600;
  color: var(--text-strong); margin-bottom: .3rem;
}
label.f > span.lbl .req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=url], input[type=date], input[type=tel], select, textarea {
  width: 100%; padding: .58rem .7rem; border: 1px solid var(--line);
  border-radius: var(--r-sm); font: inherit; font-size: .89rem;
  color: var(--text-strong); background: #fff;
}
textarea { min-height: 110px; resize: vertical; font-family: inherit; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
input:disabled, select:disabled, textarea:disabled { background: #F8FAFC; color: var(--muted); }
.hint { font-size: .78rem; color: var(--muted); margin-top: .25rem; }
.err  { font-size: .8rem; color: var(--danger); margin-top: .3rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; margin: 0 0 1rem; }
legend { font-size: .8rem; font-weight: 700; padding: 0 .4rem; color: var(--text-strong); }

/* ---------- tables ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: .87rem; }
table.tbl th {
  text-align: left; padding: .6rem .75rem; background: #F8FAFC;
  border-bottom: 1px solid var(--line); font-size: .72rem; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
  white-space: nowrap;
}
table.tbl td { padding: .62rem .75rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--hover); }
.tbl-wrap { overflow-x: auto; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); font-size: .9rem; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: .16rem .5rem; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  background: var(--info-bg); color: var(--primary); white-space: nowrap;
}
.badge.ok     { background: var(--ok-bg);     color: #15803D; }
.badge.warn   { background: var(--warn-bg);   color: #B45309; }
.badge.danger { background: var(--danger-bg); color: #B91C1C; }
.badge.muted  { background: #F1F5F9;          color: var(--muted); }
.badge.violet { background: #F3E8FF;          color: #7E22CE; }

/* ---------- notices ---------- */
.notice {
  padding: .75rem .9rem; border-radius: var(--r); font-size: .86rem;
  margin-bottom: .9rem; border: 1px solid transparent;
}
.notice.info   { background: var(--info-bg);   border-color: #BFDBFE; color: #1E40AF; }
.notice.ok     { background: var(--ok-bg);     border-color: #BBF7D0; color: #166534; }
.notice.warn   { background: var(--warn-bg);   border-color: #FDE68A; color: #92400E; }
.notice.danger { background: var(--danger-bg); border-color: #FECACA; color: #991B1B; }

/* ---------- auth / centred pages ---------- */
.centred {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(900px 420px at 15% -5%, rgba(22,131,255,.10), transparent 60%),
    radial-gradient(700px 380px at 105% 105%, rgba(147,51,234,.10), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 410px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1.9rem; box-shadow: var(--shadow-lg);
}
.auth-card .brand-lg {
  font-family: Manrope, sans-serif; font-size: 1.35rem; font-weight: 800;
  color: var(--navy); text-align: center; margin-bottom: .15rem;
  display: flex; align-items: center; justify-content: center; gap: .5rem;
}
.auth-card .brand-lg .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--grad); }
.auth-card .tagline { text-align: center; color: var(--muted); font-size: .86rem; margin-bottom: 1.5rem; }
.tabs { display: flex; gap: .25rem; background: #F1F5F9; padding: .25rem;
  border-radius: var(--r); margin-bottom: 1.25rem; }
.tabs button {
  flex: 1; padding: .48rem; border: 0; border-radius: var(--r-sm); background: transparent;
  font: inherit; font-size: .86rem; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tabs button.on { background: #fff; color: var(--text-strong); box-shadow: var(--shadow); }
.divider { display: flex; align-items: center; gap: .6rem; margin: 1rem 0;
  color: var(--faint); font-size: .76rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ---------- scanner ---------- */
.scan-zones { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .scan-zones { grid-template-columns: 1fr; } }
.zone {
  border: 2px dashed var(--line); border-radius: var(--r-lg); padding: 1.1rem;
  text-align: center; background: #FBFCFE; transition: border-color .15s var(--ease);
}
.zone.filled { border-style: solid; border-color: var(--primary); }
.zone img { max-width: 100%; max-height: 190px; border-radius: var(--r); margin-bottom: .6rem; }
.zone .zlabel { font-weight: 700; color: var(--text-strong); font-size: .9rem; }
.queue { display: flex; flex-direction: column; gap: .5rem; }
.qrow {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem;
  border: 1px solid var(--line); border-radius: var(--r); font-size: .86rem;
}
.qrow .qname { font-weight: 600; color: var(--text-strong); flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spin { width: 13px; height: 13px; border: 2px solid var(--line);
  border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- misc ---------- */
.pill-tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pill-tabs button {
  padding: .34rem .78rem; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font: inherit; font-size: .82rem; font-weight: 600;
  color: var(--muted); cursor: pointer;
}
.pill-tabs button.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.msg { padding: .6rem .8rem; border-radius: var(--r); font-size: .86rem; margin-bottom: .5rem; max-width: 78%; }
.msg.out { background: var(--info-bg); margin-left: auto; }
.msg.in  { background: #F1F5F9; }
.msg .meta { font-size: .72rem; color: var(--muted); margin-top: .25rem; }
.bar { height: 6px; background: var(--line-soft); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--grad); }
.modal-bg {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal {
  background: #fff; border-radius: var(--r-lg); padding: 1.5rem;
  max-width: 620px; width: 100%; max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
#toast {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 200;
  display: flex; flex-direction: column; gap: .5rem; max-width: 380px;
}
#toast .t {
  padding: .7rem .9rem; border-radius: var(--r); font-size: .86rem;
  background: var(--navy); color: #fff; box-shadow: var(--shadow-lg);
  animation: pop .18s var(--ease);
}
#toast .t.ok     { background: var(--ok); }
#toast .t.warn   { background: var(--warn); }
#toast .t.danger { background: var(--danger); }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .sidebar nav { display: flex; overflow-x: auto; padding: .4rem; }
  .sidebar nav .grp, .sidebar .who { display: none; }
  .sidebar nav a { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; }
  .sidebar nav a.on { border-left: 0; border-bottom-color: var(--sky); }
  .main { padding: 1.1rem .9rem 2.5rem; }
}
