/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Courier New', Courier, monospace;
  background: #0d0d0d;
  color: #ccc;
  font-size: clamp(14px, 1.2vw, 17px);
  -webkit-font-smoothing: antialiased;
}

/* ── CSS Variables ───────────────────────────────────────────────────────── */
:root {
  --bg0:   #0d0d0d;
  --bg1:   #111111;
  --bg2:   #141414;
  --bg3:   #161616;
  --bg4:   #1a1a1a;
  --bg5:   #1e1e1e;

  --border0: #1a1a1a;
  --border1: #222222;
  --border2: #2a2a2a;
  --border3: #333333;
  --border4: #444444;

  --text0: #eeeeee;
  --text1: #cccccc;
  --text2: #aaaaaa;
  --text3: #888888;
  --text4: #666666;
  --text5: #444444;

  --red:    #f55;
  --red-bg: #1a0000;
  --red-border: #3a1a1a;

  --amber:    #fa0;
  --amber-bg: #1a1200;
  --amber-border: #4a3a00;

  --green:    #4c4;
  --green-bg: #001a00;
  --green-border: #1a4a1a;

  --blue:    #5af;
  --blue-bg: #001020;
  --blue-border: #1a3a5a;

  --purple:    #c8f;
  --purple-bg: #100a20;
  --purple-border: #3a1a5a;

  --accent: #fa0;

  --radius-sm: 3px;
  --radius-md: 5px;
  --radius-lg: 8px;
}

/* ── Screens ─────────────────────────────────────────────────────────────── */
#app { width: 100%; height: 100%; position: relative; }
.screen { display: none; width: 100%; height: 100%; overflow: hidden; }
.screen.active { display: flex; flex-direction: column; }

/* ── Login / Register ────────────────────────────────────────────────────── */
.login-wrap {
  margin: auto;
  width: 100%;
  max-width: 380px;
  padding: 2rem 1.5rem;
}
.login-logo {
  font-size: 2rem;
  font-weight: 700;
  color: var(--amber);
  letter-spacing: .06em;
  margin-bottom: .25rem;
  text-align: center;
}
.login-sub {
  font-size: .8rem;
  color: var(--text4);
  text-align: center;
  margin-bottom: 2rem;
}
.login-form { display: flex; flex-direction: column; gap: .9rem; }
.lf-field { display: flex; flex-direction: column; gap: .3rem; }
.lf-field label { font-size: .72rem; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; }
.lf-field input {
  background: var(--bg3);
  border: 1px solid var(--border3);
  border-radius: var(--radius-sm);
  color: var(--text1);
  font-family: inherit;
  font-size: .85rem;
  padding: .55rem .7rem;
  width: 100%;
  transition: border-color .15s;
}
.lf-field input:focus { outline: none; border-color: var(--amber); }
.lf-error { font-size: .75rem; color: var(--red); min-height: 1rem; }
.lf-submit {
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  border-radius: var(--radius-sm);
  color: var(--amber);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 700;
  padding: .65rem;
  cursor: pointer;
  transition: background .15s;
  margin-top: .4rem;
}
.lf-submit:hover { background: #2a1a00; }
.lf-submit:disabled { opacity: .5; cursor: not-allowed; }
.lf-link { font-size: .75rem; color: var(--blue); text-align: center; text-decoration: none; }
.lf-link:hover { text-decoration: underline; }

/* ── Shared pill / badge ─────────────────────────────────────────────────── */
.pill {
  display: inline-block;
  font-size: .68rem;
  padding: .12rem .45rem;
  border-radius: 2px;
  border: 1px solid;
  white-space: nowrap;
}
.pill-r  { background: var(--red-bg);    color: var(--red);    border-color: var(--red-border); }
.pill-a  { background: var(--amber-bg);  color: var(--amber);  border-color: var(--amber-border); }
.pill-g  { background: var(--green-bg);  color: var(--green);  border-color: var(--green-border); }
.pill-b  { background: var(--blue-bg);   color: var(--blue);   border-color: var(--blue-border); }
.pill-p  { background: var(--purple-bg); color: var(--purple); border-color: var(--purple-border); }
.pill-x  { background: var(--bg4);       color: var(--text4);  border-color: var(--border2); }

/* ── Shared button ───────────────────────────────────────────────────────── */
.btn {
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .72rem;
  padding: .3rem .7rem;
  border: 1px solid;
  cursor: pointer;
  white-space: nowrap;
  transition: background .1s;
}
.btn-g   { background: var(--green-bg);  border-color: var(--green);  color: var(--green); }
.btn-g:hover  { background: #002a00; }
.btn-b   { background: var(--blue-bg);   border-color: var(--blue);   color: var(--blue); }
.btn-b:hover  { background: #001a30; }
.btn-a   { background: var(--amber-bg);  border-color: var(--amber);  color: var(--amber); }
.btn-a:hover  { background: #2a1a00; }
.btn-r   { background: var(--red-bg);    border-color: var(--red);    color: var(--red); }
.btn-r:hover  { background: #2a0000; }
.btn-x   { background: var(--bg4);       border-color: var(--border3); color: var(--text3); }
.btn-x:hover  { background: var(--bg5); color: var(--text1); }

/* ── Shared input / select / textarea ───────────────────────────────────── */
.inp, .sel, .ta {
  background: var(--bg3);
  border: 1px solid var(--border3);
  border-radius: var(--radius-sm);
  color: var(--text1);
  font-family: inherit;
  font-size: .78rem;
  padding: .3rem .55rem;
}
.inp:focus, .sel:focus, .ta:focus { outline: none; border-color: var(--amber); }
.ta { resize: none; }

/* ── Toggle switch ───────────────────────────────────────────────────────── */
.toggle {
  width: 32px; height: 18px;
  background: var(--border2);
  border-radius: 9px;
  cursor: pointer;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
  display: inline-block;
}
.toggle.on { background: #1a5a1a; }
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: var(--text3);
  border-radius: 50%;
  transition: transform .2s, background .2s;
}
.toggle.on::after { transform: translateX(14px); background: var(--green); }

/* ── Toast notifications ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  font-size: .78rem;
  padding: .55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: auto;
  max-width: 320px;
}
.toast.show   { opacity: 1; transform: translateY(0); }
.toast.hide   { opacity: 0; transform: translateY(8px); }
.toast-ok     { background: var(--green-bg);  color: var(--green);  border-color: var(--green-border); }
.toast-info   { background: var(--blue-bg);   color: var(--blue);   border-color: var(--blue-border); }
.toast-warn   { background: var(--amber-bg);  color: var(--amber);  border-color: var(--amber-border); }
.toast-error  { background: var(--red-bg);    color: var(--red);    border-color: var(--red-border); }

/* ── Modal overlay ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-box {
  background: var(--bg3);
  border: 1px solid var(--border3);
  border-radius: var(--radius-md);
  overflow: hidden;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-head {
  background: var(--bg1);
  border-bottom: 1px solid var(--border1);
  padding: .6rem .9rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}
.modal-head-title { font-size: .85rem; font-weight: 700; color: var(--text0); flex: 1; }
.modal-body { padding: .9rem; overflow-y: auto; flex: 1; }
.modal-foot {
  background: var(--bg1);
  border-top: 1px solid var(--border1);
  padding: .6rem .9rem;
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border3); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--border4); }

/* ── Shared table ────────────────────────────────────────────────────────── */
.data-tbl { width: 100%; border-collapse: collapse; }
.data-tbl th {
  background: var(--bg0);
  color: var(--text4);
  font-size: .65rem;
  font-weight: 400;
  padding: .4rem .6rem;
  text-align: left;
  border-bottom: 1px solid var(--border1);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.data-tbl td {
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--border0);
  font-size: .75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  vertical-align: middle;
}
.data-tbl tr:hover td { background: var(--bg3); }
.data-tbl tr.sel td   { background: #0d1a0d; }

/* ── Config rows ─────────────────────────────────────────────────────────── */
.cfg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .55rem 0;
  border-bottom: 1px solid var(--border0);
  gap: .75rem;
}
.cfg-row:last-child { border-bottom: none; }
.cfg-key  { font-size: .78rem; color: var(--text2); }
.cfg-hint { font-size: .65rem; color: var(--text4); margin-top: .1rem; }
.cfg-section { padding: .9rem 1rem; border-bottom: 1px solid var(--border1); }
.cfg-title {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text0);
  margin-bottom: .6rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Stat cards ──────────────────────────────────────────────────────────── */
.stat-card { background: var(--bg2); padding: .75rem .9rem; }
.stat-card .lbl { font-size: .62rem; color: var(--text4); text-transform: uppercase; letter-spacing: .07em; margin-bottom: .25rem; }
.stat-card .val { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.stat-card .sub { font-size: .65rem; color: var(--text4); margin-top: .2rem; }


