/* Component styles for the original vanilla panel.
 * Design tokens live in theme.css, which every consumer links FIRST.
 */
* { box-sizing: border-box; }

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

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--dim); }
.small { font-size: 12.5px; }
[hidden] { display: none !important; }

.label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
}

.wordmark {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Buttons ---------------------------------------------------------------- */
.btn {
  border: 1px solid var(--line-strong);
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
}
.btn:hover:not(:disabled) { background: var(--surface); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-danger { color: var(--bad); border-color: var(--bad-line); background: var(--bg); }
.btn-danger:hover:not(:disabled) { background: var(--bad-bg); }
.btn-quiet { border-color: var(--line); color: var(--dim); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }

input[type="text"], input[type="password"], input[type="number"], select {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 11px;
  background: var(--bg);
  min-width: 0;
}
input:focus, select:focus, .btn:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 1px;
}

.field-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.field-row input[type="text"], .field-row input[type="password"] { flex: 1 1 240px; }

.error { color: var(--bad); font-size: 13px; margin: 10px 0 0; }

/* Gate ------------------------------------------------------------------- */
.gate {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); padding: 24px; z-index: 40;
}
.gate-card {
  width: 100%; max-width: 460px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 14px; padding: 32px;
}
.gate-head h1 { font-size: 21px; margin: 18px 0 6px; }
.gate-head p { margin: 0; font-size: 13.5px; }
.gate-list { display: flex; flex-direction: column; gap: 8px; margin: 24px 0; }
.gate-list:empty { display: none; }
.person {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); cursor: pointer;
}
.person:hover { border-color: var(--line-strong); background: var(--surface); }
.person .who-role { font-size: 12px; color: var(--faint); }
.gate-new { border-top: 1px solid var(--line); padding-top: 20px; }

/* Shell ------------------------------------------------------------------ */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex: 0 0 232px;
  border-right: 1px solid var(--line);
  padding: 26px 18px; display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  text-align: left; background: none; border: 0; border-radius: 8px;
  padding: 9px 11px; color: var(--dim); cursor: pointer;
}
.nav-item:hover { background: var(--surface); color: var(--ink); }
.nav-item.active { background: var(--nav-active); color: var(--ink); font-weight: 550; }

.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 16px; }
.who-name { font-weight: 550; }
.who-role { font-size: 12px; color: var(--faint); text-transform: capitalize; }
.sidebar-foot .btn { width: 100%; margin-top: 12px; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 22px 32px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.topbar h2 { font-size: 18px; }
.account-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 12px; color: var(--dim); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 11px; background: var(--bg);
}
.chip b { color: var(--ink); font-weight: 550; }
.chip.bad { color: var(--bad); border-color: var(--bad-line); background: var(--bad-bg); }

.view { padding: 26px 32px 60px; display: flex; flex-direction: column; gap: 20px; max-width: 1080px; }

.panel { border: 1px solid var(--line); border-radius: 12px; padding: 22px; background: var(--bg); }
.panel-title { font-weight: 600; margin-bottom: 14px; }

.notice {
  border: 1px solid var(--warn-line); background: var(--warn-bg); color: var(--warn);
  border-radius: 10px; padding: 13px 16px; font-size: 13.5px;
}
.notice-soft { border-color: var(--line); background: var(--surface); color: var(--dim); }
.notice a, .notice button.link { color: inherit; text-decoration: underline; }

/* Renting ---------------------------------------------------------------- */
.service-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.service-name { font-size: 19px; font-weight: 600; margin-top: 4px; }
.stock-box { text-align: right; }
.stock-value { font-size: 19px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.service-note { margin: 16px 0 20px; font-size: 13px; max-width: 62ch; }

.order-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.phone-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; }
.phone {
  font-size: 27px; font-weight: 600; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.timer-box { text-align: right; }
.timer { font-size: 27px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 4px; }
.timer.low { color: var(--bad); }

.progress { height: 3px; background: var(--line); border-radius: 3px; margin: 18px 0 22px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); width: 100%; transition: width 1s linear; }

.code-area { border-top: 1px solid var(--line); padding-top: 18px; }
.code-list { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.code-item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.code-value {
  font-size: 25px; font-weight: 600; letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums; color: var(--ok);
}
.code-extra {
  font-size: 12px; color: var(--warn); background: var(--warn-bg);
  border: 1px solid var(--warn-line); border-radius: 999px; padding: 2px 9px;
}
.waiting { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 14px; }
.dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--dim);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .25 } 50% { opacity: 1 } }

.order-actions { display: flex; align-items: center; gap: 14px; margin-top: 22px; flex-wrap: wrap; }

/* Tables ----------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line);
  font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--faint); font-weight: 600; white-space: nowrap;
}
td { padding: 11px 12px 11px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num, th.num { font-variant-numeric: tabular-nums; }
.empty { color: var(--faint); padding: 16px 0; font-size: 13.5px; }

.tag {
  display: inline-block; font-size: 11.5px; font-weight: 550;
  border-radius: 999px; padding: 3px 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--dim); white-space: nowrap;
}
.tag.success { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.tag.expired { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-line); }
.tag.canceled { color: var(--dim); }
.tag.active { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.tag.admin { color: var(--ink); background: var(--nav-active); border-color: var(--line-strong); }

.code-cell { font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }

/* Cards ------------------------------------------------------------------ */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; }
.card { border: 1px solid var(--line); border-radius: 12px; padding: 18px; background: var(--bg); }
.card-value { font-size: 28px; font-weight: 600; margin-top: 8px; font-variant-numeric: tabular-nums; }
.card-note { font-size: 12px; color: var(--faint); margin-top: 4px; }
.card.ok .card-value { color: var(--ok); }
.card.bad .card-value { color: var(--bad); }

.stats-controls { margin-bottom: 4px; }

/* Settings --------------------------------------------------------------- */
.kv { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; font-size: 13.5px; }
.kv .label { min-width: 132px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.settings-form { margin-top: 18px; }

/* Modal + toast ---------------------------------------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: var(--scrim); padding: 24px;
}
.modal-card {
  background: var(--bg); border-radius: 14px; padding: 26px; max-width: 430px; width: 100%;
  border: 1px solid var(--line);
}
.modal-card h3 { font-size: 17px; margin-bottom: 10px; }
.modal-card p { margin: 0; font-size: 13.5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: var(--accent-ink); padding: 10px 18px; border-radius: 9px;
  font-size: 13.5px; z-index: 60;
}

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin-top: 0; }
  .sidebar-foot .btn { width: auto; }
  .view, .topbar { padding-left: 18px; padding-right: 18px; }
}
