:root {
  --ink: #000;
  --paper: #fff;
  --beige: #f5f1e8;
  --grey: #808080;
  --red: #d32011;
  --blue: #1f5eff;
  --taupe: #b38b6d;
  --line: #e3dccb;
  --hairline: 1px solid var(--ink);
  --font: "Inter", -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  background: var(--paper);
  color: var(--ink);
}
button { font: inherit; cursor: pointer; }
a { color: var(--ink); text-decoration: none; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 2rem; }
.topbar {
  display: flex;
  align-items: center;
  min-height: 64px;
  gap: 1.5rem;
  border-bottom: var(--hairline);
  padding: .5rem 2rem .5rem 1rem;
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--paper);
}
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; margin-right: auto; }
.brand-mark { width: 28px; height: 28px; background: var(--blue); color: var(--paper); display: grid; place-items: center; font-weight: 900; font-size: .75rem; }
.admin-body { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 1.5rem; padding: 2rem 2rem 2rem .75rem; max-width: 1440px; margin: 0 auto; }
.sidebar { border: 1px solid var(--line); align-self: start; position: sticky; top: 76px; max-height: calc(100vh - 88px); overflow-y: auto; background: var(--paper); z-index: 20; }
.sidebar h2 { padding: .9rem 1.2rem; border-bottom: var(--hairline); font-size: .8rem; text-transform: uppercase; color: var(--grey); }
.side-list { list-style: none; }
.side-list a { display: flex; align-items: center; gap: .6rem; padding: .75rem 1.2rem; border-bottom: var(--hairline); font-weight: 500; }
.side-list a:last-child { border-bottom: 0; }
.side-list a:hover { background: var(--beige); color: var(--red); }
.side-list a.active { background: var(--blue); color: var(--paper); border-left: 4px solid var(--ink); }
.content { min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; border-bottom: var(--hairline); padding-bottom: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }
.eyebrow { font-size: .8rem; text-transform: uppercase; color: var(--grey); }
h1 { font-size: 2.5rem; font-weight: 900; line-height: 1.15; }
h2 { font-size: 1.5rem; font-weight: 800; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-left: var(--hairline); border-right: var(--hairline); margin-bottom: 2rem; }
.stat { padding: 1.2rem; border-bottom: var(--hairline); }
.stat + .stat { border-left: var(--hairline); }
.stat .label { font-size: .75rem; text-transform: uppercase; color: var(--grey); font-weight: 700; }
.stat .value { display: block; font-size: 2rem; font-weight: 900; line-height: 1.2; }
.stat:nth-child(1) .value { color: var(--red); }
.stat:nth-child(2) .value { color: var(--blue); }
.stat:nth-child(3) .value { color: var(--taupe); }
.panel { border: var(--hairline); margin-bottom: 2rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.2rem; border-bottom: var(--hairline); flex-wrap: wrap; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { text-align: left; padding: .75rem 1.2rem; border-bottom: var(--hairline); font-size: .875rem; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { font-size: .75rem; text-transform: uppercase; color: var(--grey); background: var(--beige); }
td.wrap { white-space: normal; word-break: break-word; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px; padding: .55rem 1.1rem; border: var(--hairline); background: var(--paper); font-weight: 700; font-size: .875rem; }
.btn-primary { background: var(--blue); color: var(--paper); border-color: var(--blue); }
.btn-primary:hover { background: var(--ink); border-color: var(--ink); }
.btn-secondary:hover { background: var(--ink); color: var(--paper); }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: var(--paper); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem 2rem; max-width: 760px; }
.field { display: flex; flex-direction: column; gap: .4rem; }
.field.full { grid-column: 1 / -1; }
label { font-size: .8rem; font-weight: 700; text-transform: uppercase; }
input, select, textarea { font: inherit; padding: .65rem .8rem; border: 1px solid var(--line); background: var(--paper); width: 100%; border-radius: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 2px; border-color: var(--blue); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--blue); }
.field-label { font-size: .8rem; font-weight: 700; text-transform: uppercase; }
.switch-row { display: flex; align-items: center; gap: .75rem; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 46px; height: 26px; border: 1px solid var(--line); background: var(--paper); position: relative; flex: none; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: var(--grey); transition: transform 160ms; }
.switch-row input:checked + .switch-track { background: var(--blue); border-color: var(--blue); }
.switch-row input:checked + .switch-track::after { transform: translateX(20px); background: var(--paper); }
.switch-row input:focus-visible + .switch-track { outline: 2px solid var(--blue); outline-offset: 2px; }
.switch-text { font-size: .875rem; font-weight: 500; }
textarea { min-height: 90px; resize: vertical; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.tag { display: inline-flex; align-items: center; gap: .4rem; border: var(--hairline); padding: .2rem .55rem; font-size: .75rem; font-weight: 700; }
.tag .dot { width: 7px; height: 7px; background: var(--red); }
.tag.online .dot { background: var(--blue); }
.tag.off { color: var(--grey); }
.tag.off .dot { background: var(--grey); }
.flash { border: 1px solid var(--line); border-left: 6px solid var(--red); background: var(--beige); padding: .8rem 1rem; margin-bottom: 1rem; font-size: .875rem; }
.hint { margin-top: .35rem; font-size: .8rem; color: var(--blue); }
.filter-row { display: flex; align-items: flex-end; gap: .75rem; padding: 1rem 1.2rem; border-bottom: var(--hairline); flex-wrap: wrap; }
.filter-row select { max-width: 260px; }
.modal-mask { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: none; align-items: center; justify-content: center; z-index: 60; padding: 1rem; }
.modal-mask.open { display: flex; }
.modal { background: var(--paper); border: 1px solid var(--ink); width: 100%; max-width: 580px; max-height: 82vh; overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: var(--hairline); }
.modal-head h2 { font-size: 1.1rem; font-weight: 900; }
.modal-body { padding: 1.25rem; }
.modal-body .mono { display: block; word-break: break-all; margin-bottom: .75rem; }
.modal-close { width: 34px; height: 34px; display: grid; place-items: center; border: var(--hairline); background: var(--paper); font-size: 1rem; }
.modal-close:hover { background: var(--ink); color: var(--paper); }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--paper); }
.icon-btn:hover { background: var(--blue); color: var(--paper); border-color: var(--blue); }
.qr-box { display: grid; place-items: center; padding: 1rem; border: 1px solid var(--line); background: var(--paper); margin-bottom: 1rem; }
.qr-box img { max-width: 280px; width: 100%; height: auto; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.login-box { width: 100%; max-width: 440px; border: var(--hairline); padding: 2.5rem; }
.error { border: 2px solid var(--red); padding: .8rem 1rem; margin-bottom: 1rem; color: var(--red); font-size: .875rem; }
.code-card { max-width: 640px; border: var(--hairline); padding: 2.5rem; margin: 3rem auto; }
.code-row { display: grid; grid-template-columns: repeat(6, minmax(44px, 1fr)); gap: .75rem; max-width: 460px; margin: 1.5rem 0; }
.code-row span { min-height: 64px; display: grid; place-items: center; border: var(--hairline); font-size: 1.75rem; font-weight: 900; }
.code-row span:nth-child(3n) { background: var(--beige); }
.status-line { display: flex; align-items: center; gap: .6rem; font-weight: 700; margin-bottom: 1rem; }
.status-line .dot { width: 10px; height: 10px; background: var(--red); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (max-width: 900px) {
  .admin-body { grid-template-columns: 1fr; padding: 1rem; }
  .topbar { padding: .5rem 1rem; }
  .wrap { padding: 0 1rem; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
}
