:root {
  --bg: #12141a;
  --panel: #1b1e26;
  --panel-2: #232733;
  --line: #2f3542;
  --text: #e7e9ee;
  --muted: #98a0b0;
  --accent: #4c8dff;
  --good: #35c46a;
  --warn: #e2b33c;
  --bad: #e35d5d;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.small { font-size: 12px; color: var(--muted); }
.meta { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.hint { color: var(--muted); font-size: 13px; margin-top: 18px; }
.error { color: var(--bad); }

/* ------------------------------------------------------------------- chrome */

.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 0 22px; height: 56px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; color: var(--text); letter-spacing: .2px; }
.topbar nav { display: flex; gap: 16px; margin-right: auto; }
.topbar nav a { color: var(--muted); padding: 4px 0; border-bottom: 2px solid transparent; }
.topbar nav a.on { color: var(--text); border-bottom-color: var(--accent); }
.topbar nav a:hover { color: var(--text); text-decoration: none; }
.signout { display: flex; align-items: center; gap: 12px; margin: 0; }
.who { color: var(--muted); font-size: 13px; }

main { max-width: 1120px; margin: 0 auto; padding: 26px 22px 60px; }
h1 { font-size: 22px; margin: 0 0 18px; }
h2 { font-size: 16px; margin: 0 0 12px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 22px;
}
.card.narrow { max-width: 460px; }
.count { color: var(--muted); font-weight: 400; font-size: 13px; }

/* ------------------------------------------------------------------- forms */

label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
input[type=text], input:not([type]), input[type=password], select {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; font-size: 14px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button, .button {
  display: inline-block; padding: 9px 15px; font-size: 14px; cursor: pointer;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px;
}
button:hover, .button:hover { border-color: var(--muted); text-decoration: none; }
button:disabled, .button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 550; }
.danger { color: var(--bad); }
button.link {
  background: none; border: none; padding: 0; color: var(--accent);
  font-size: 13px; text-decoration: underline;
}
form.inline { display: inline; margin: 0; }

/* ------------------------------------------------------------ device cards */

.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.device {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.device.busy { opacity: .72; }
.device-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.device h2 { margin: 0; font-size: 15px; }
.device .status { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.device .holder { font-size: 13px; margin: 2px 0 10px; min-height: 20px; }
.device .button { text-align: center; margin-top: auto; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.state-device .dot { background: var(--good); }
.state-unauthorized .dot, .state-offline .dot { background: var(--warn); }
.state-gone .dot { background: var(--bad); }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; background: var(--panel-2); color: var(--muted);
}
.pill.good { background: rgba(53,196,106,.15); color: var(--good); }
.pill.warn { background: rgba(226,179,60,.15); color: var(--warn); }
.pill.bad  { background: rgba(227,93,93,.15); color: var(--bad); }

/* ------------------------------------------------------------ device page */

.device-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.device-page-actions { display: flex; gap: 10px; }
.banner {
  margin: 18px 0; padding: 12px 15px; border-radius: 8px; font-size: 14px;
  border: 1px solid var(--line); background: var(--panel);
}
.banner.good { border-color: rgba(53,196,106,.5); }
.banner.bad { border-color: rgba(227,93,93,.5); color: var(--bad); }
.banner:empty { display: none; }
.screen {
  background: #000; border: 1px solid var(--line); border-radius: var(--radius);
  min-height: 420px; display: flex; align-items: center; justify-content: center;
  position: relative; padding: 12px;
}
.screen-placeholder { color: var(--muted); text-align: center; max-width: 420px; padding: 30px; font-size: 14px; }

/* The phone itself. Height-bound so a tall handset fits without scrolling. */
#screen-canvas {
  max-height: calc(100vh - 260px); max-width: 100%;
  height: auto; width: auto; display: none;
  border-radius: 6px; background: #000;
  touch-action: none;                    /* we handle every gesture ourselves */
  outline: none; cursor: crosshair;
}
#screen-canvas:focus { box-shadow: 0 0 0 2px rgba(90,150,255,.55); }
.screen.live #screen-canvas { display: block; }
.screen.live .screen-placeholder { display: none; }

.screen-note {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; font-size: 13px;
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line);
  max-width: 90%; text-align: center;
}
.screen-note.hidden, .screen-note:empty { display: none; }
.screen-note.bad { color: var(--bad); border-color: rgba(227,93,93,.5); }

/* Back / Home / Recents — the three buttons the phone itself would have. */
.phone-keys { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.phone-keys button { min-width: 92px; }
.screen-help { color: var(--muted); font-size: 12px; text-align: center; margin: 10px 0 0; }

/* A problem the admin has to go and fix on a physical box. */
.callout {
  background: rgba(226,179,60,.12); border: 1px solid rgba(226,179,60,.45);
  border-radius: var(--radius); padding: 11px 13px; font-size: 14px; margin: 14px 0 0;
}

/* ----------------------------------------------------------------- tables */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 8px 10px; color: var(--muted);
  font-weight: 500; font-size: 12px; border-bottom: 1px solid var(--line);
}
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.rename { display: flex; gap: 8px; align-items: center; margin: 0 0 4px; }
.rename input { margin-top: 0; }

ul.plain, ul.checklist { list-style: none; padding: 0; margin: 0 0 16px; }
ul.checklist li { border-bottom: 1px solid var(--line); }
ul.checklist label {
  display: flex; align-items: center; gap: 10px;
  margin: 0; padding: 9px 2px; color: var(--text); font-size: 14px; cursor: pointer;
}
ul.checklist input { width: auto; margin: 0; }
.cl-name { flex: 1; }

.setup { margin-top: 16px; }
.setup summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.token { word-break: break-all; background: var(--panel-2); padding: 10px; border-radius: 7px; font-size: 12px; }

.setup-lead { margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; }
.setup-lead p { margin: 0 0 10px; }
.setup-lead p:last-child { margin-bottom: 0; }
