:root {
  --bg: #0f1419;
  --panel: #171e27;
  --card: #1d2630;
  --line: #2a3542;
  --text: #eef3f8;
  --muted: #93a4b8;
  --accent: #e23d3d;
  --ok: #3dba8b;
  --warn: #e6b325;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}
body.modal-open { overflow: hidden; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; margin: 0 0 10px; }
.error { color: #ff7a7a; }
.eyebrow { letter-spacing: 0.12em; text-transform: uppercase; font-size: 12px; color: var(--accent); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
label { display: block; margin: 12px 0; font-size: 13px; color: var(--muted); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 44px; }
.eye-btn {
  position: absolute; right: 8px; bottom: 8px; width: auto; margin: 0; padding: 4px 8px;
  background: transparent; color: var(--muted); border: 0; cursor: pointer;
}
input, select, textarea, button {
  width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit;
}
button { background: var(--accent); border: 0; font-weight: 600; cursor: pointer; }
button.ghost { background: transparent; border: 1px solid var(--line); }
button.small { width: auto; padding: 6px 10px; font-size: 12px; margin: 0 6px 6px 0; }
#app-view { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
#app-view[hidden], [hidden] { display: none !important; }
aside {
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 8px;
  position: sticky; top: 0; height: 100vh;
}
.brand { font-weight: 700; margin-bottom: 16px; }
.brand span { color: var(--muted); font-weight: 400; font-size: 13px; }
nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
nav button { background: transparent; text-align: left; }
nav button.active { background: #2a1313; }
main { padding: 24px; overflow: auto; min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat b { display: block; font-size: 28px; margin-top: 6px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.toolbar input, .toolbar select { margin: 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; }
.badge.flagged { background: #3a1c12; color: #ffb087; }
.badge.normal { background: #163226; color: var(--ok); }
.badge.warned { background: #3a3212; color: var(--warn); }
.badge.restricted { background: #2a2438; color: #c5b3ff; }
.badge.suspended { background: #3a1218; color: #ff8a9a; }

/* Thresholds layout */
.settings-layout { display: grid; gap: 16px; max-width: 1100px; }
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.settings-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}
.settings-card h3 { margin: 0 0 4px; font-size: 15px; color: var(--text); }
.settings-wide { grid-column: 1 / -1; }
.settings-save button { max-width: 220px; }
.field-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.field-row label { margin: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0 0; }
.check input { width: auto; margin: 2px 0 0; flex: 0 0 auto; }

/* Drawer: fixed shell, only body scrolls */
.drawer {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: grid; justify-items: end; z-index: 30;
}
.drawer-panel {
  width: min(720px, 100%);
  height: 100vh;
  max-height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.drawer-head {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.drawer-head h3 { margin: 0; font-size: 18px; }
.drawer-head .muted { margin: 4px 0 0; font-size: 12px; word-break: break-all; }
.drawer-head .close { width: auto; margin: 0; }
.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px 28px;
  -webkit-overflow-scrolling: touch;
}
.drawer-meta { margin: 0 0 12px; }
.drawer-action-box {
  margin: 12px 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.drawer-actions { margin: 12px 0 8px; }
.history { font-size: 12px; }
.clickable { cursor: pointer; }
.clickable:hover { background: #1b2430; }
.toolbar-wrap { flex-wrap: wrap; }
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.pager button { width: auto; min-width: 88px; margin: 0; }
.pager .pager-info { color: var(--muted); font-size: 13px; }
.badge.sms-sent { background: #163226; color: var(--ok); }
.badge.sms-failed { background: #3a1218; color: #ff8a9a; }
.badge.sms-held { background: #3a3212; color: var(--warn); }
.badge.sms-other { background: #1c2836; color: #9eb4cc; }
#sms-meta { margin: 0 0 10px; }
.drawer-sms-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 18px 0 8px;
}
.drawer-sms-head h4 { margin: 0; }
.drawer-sms-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.drawer-sms-tools select { width: auto; min-width: 120px; margin: 0; }

.confirm-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: grid; place-items: center; z-index: 80; padding: 20px;
}
.confirm-card { width: min(420px, 100%); }
.confirm-reason {
  margin: 12px 0; padding: 10px 12px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text); font-size: 13px;
}
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.confirm-actions button { width: auto; min-width: 110px; }
#confirm-ok.danger { background: #b42318; }

@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  #app-view { grid-template-columns: 1fr; }
  aside { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
}
