/* Touchbud RemoteDroid — brand theme (black / white / #e2171d red) */
:root {
    --red: #e2171d;
    --red-dark: #c11318;
    --ink: #16181d;
    --ink-soft: #55606b;
    --line: #e7e9ee;
    --bg: #f6f7f9;
    --card: #ffffff;
    --ok: #1faa55;
    --off: #aab2bd;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(20,22,28,.05), 0 6px 20px rgba(20,22,28,.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.55 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

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

/* ---- top bar ---- */
header.topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 14px 22px; background: var(--card);
    border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { height: 26px; width: auto; display: block; }
.brand .sub { font-size: 13px; color: var(--ink-soft); font-weight: 600; letter-spacing: .2px; }
.topbar .who { font-size: 13px; color: var(--ink-soft); }
.topbar .who b { color: var(--ink); }

main { max-width: 1080px; margin: 0 auto; padding: 26px 22px 60px; }

/* ---- buttons ---- */
button, .btn {
    font: inherit; font-weight: 600; cursor: pointer;
    background: var(--ink); color: #fff; border: 1px solid var(--ink);
    border-radius: 9px; padding: 9px 15px; display: inline-block; text-decoration: none;
    transition: transform .04s ease, background .15s ease;
}
button:hover, .btn:hover { text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
.btn-red, button.red { background: var(--red); border-color: var(--red); }
.btn-red:hover, button.red:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-ghost, button.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover, button.ghost:hover { border-color: var(--ink-soft); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }

/* ---- inputs ---- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin: 12px 0 5px; }
input, select {
    width: 100%; font: inherit; color: var(--ink); background: #fff;
    border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
}
input:focus, select:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(226,23,29,.12); }

/* ---- cards / sections ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.section { margin-bottom: 26px; }
.section > h2 { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
.section > h2 .count { color: var(--ink-soft); font-weight: 600; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--ink-soft); }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.pill.master { background: #fdecec; color: var(--red-dark); }
.pill.user { background: #eef1f5; color: var(--ink-soft); }

code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.key {
    display: inline-flex; align-items: center; gap: 8px; background: #f2f4f7;
    border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-family: ui-monospace, Consolas, monospace;
    font-size: 13px; word-break: break-all;
}

/* ---- auth screens ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 380px; max-width: 100%; background: var(--card); border: 1px solid var(--line);
    border-radius: 16px; box-shadow: var(--shadow); padding: 30px; }
.auth-card .brand { justify-content: center; margin-bottom: 10px; }
.auth-card .brand img { height: 44px; }
.auth-card h1 { font-size: 22px; text-align: center; margin: 8px 0 22px; letter-spacing: -.2px; }

/* "RemoteDroid" wordmark with a bold Touchbud-red dot on the (dotless) i */
.wordmark { font-weight: 800; line-height: 1; letter-spacing: .2px; }
.wordmark .idot { position: relative; display: inline-block; width: .34em; text-align: center; }
.wordmark .idot::after {
    content: ""; position: absolute; left: 50%; top: -.02em; transform: translate(-50%, -18%);
    width: .3em; height: .3em; border-radius: 50%; background: var(--red);
    box-shadow: 0 1px 2px rgba(226,23,29,.35);
}
.auth-card .links { margin-top: 16px; font-size: 13px; display: flex; justify-content: space-between; }
.error { background: #fdecec; border: 1px solid #f6c9cb; color: var(--red-dark); border-radius: 9px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.ok-msg { background: #e9f7ee; border: 1px solid #bfe6cd; color: #14713b; border-radius: 9px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }

/* ---- device grid ---- */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.device { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.device .name { font-weight: 700; }
.device .model { color: var(--ink-soft); font-size: 13px; }
.device .meta { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 12px; }
.device .meta dt { color: var(--ink-soft); }
.device .meta dd { margin: 0; font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--off); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(31,170,85,.15); }
.owner-tag { font-size: 12px; color: var(--ink-soft); }
.owner-tag b { color: var(--ink); }

.empty { color: var(--ink-soft); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 44px; text-align: center; }

/* ---- table ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-soft); }

/* ---- tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tab { padding: 10px 14px; font-weight: 600; color: var(--ink-soft); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--ink); border-bottom-color: var(--red); }

/* ---- control view ---- */
.control-layout { display: flex; gap: 20px; align-items: flex-start; justify-content: center; padding: 20px; flex-wrap: wrap; }
#screen { background: #000; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
    max-width: 100%; max-height: calc(100vh - 140px); cursor: crosshair; touch-action: none; }
.pad { display: flex; flex-direction: column; gap: 8px; min-width: 170px; }
.pad button { width: 100%; }
.pad .grp { display: flex; gap: 8px; }
.pad .grp button { flex: 1; }
.pad .lbl { font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-top: 8px; text-transform: uppercase; letter-spacing: .4px; }
.banner { background: #fff7e6; border: 1px solid #ffe2ad; color: #8a5a00; border-radius: 9px; padding: 9px 12px; font-size: 13px; }

/* ---- modal ---- */
.modal-bg { position: fixed; inset: 0; background: rgba(20,22,28,.45); display: grid; place-items: center; z-index: 50; }
.modal { width: 440px; max-width: 92vw; background: #fff; border-radius: 14px; padding: 24px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 14px; }
