:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #fff;
  --ink: #182220;
  --muted: #52645e;
  --line: #dce5df;
  --accent: #307049;
  --wash: #f0f7f2;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111615;
  --surface: #19211e;
  --ink: #eff5f0;
  --muted: #b2c2bb;
  --line: #354740;
  --accent: #a1dcb7;
  --wash: #24352e;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; color: var(--ink); background: var(--bg); }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-content, .workspace { width: min(100% - 64px, 1040px); margin-inline: auto; }
.topbar-content { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand {
  color: var(--ink);
  font-size: clamp(18px, 3vw, 22px);
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
}
.theme-button { min-height: 38px; padding: 8px 13px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; cursor: pointer; }
.theme-button:hover { background: var(--wash); }
.workspace { flex: 1; padding-block: 39px 56px; }
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.stat-icon.total {
    background: #e3f2fd;
    color: #1976d2;
}
.stat-icon.new {
    background: #e8f5e9;
    color: #388e3c;
}
.stat-icon.active {
    background: #fff3e0;
    color: #f57c00;
}
.stat-info {
    display: flex;
    flex-direction: column;
}
.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #333;
}
.stat-label {
    font-size: 13px;
    color: #666;
}
.device-workspace { min-width: 0; }
.device-workspace [hidden] { display: none !important; }
.device-page-header, .device-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.device-workspace .stats-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.device-workspace .stat-card { min-width: 0; padding: 16px; gap: 12px; }
.device-workspace .stat-icon { width: 42px; height: 42px; flex-shrink: 0; font-size: 20px; }
.device-workspace .stat-value { font-size: 25px; }
.device-workspace .stat-label { font-size: 12px; }
body.admin-app .device-workspace .device-page-header { margin-bottom: 16px; }
body.admin-app .device-workspace .stats-cards { gap: 10px; margin-bottom: 12px; }
body.admin-app .device-workspace .stat-card { padding: 12px 16px; }
body.admin-app .device-controls { padding: 16px; margin: 0 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
body.admin-app .device-controls-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
body.admin-app .device-controls-heading h2 { margin: 0; font-size: 15px; color: var(--ink-strong); }
body.admin-app .device-filter-grid { display: grid; grid-template-columns: minmax(220px, 2fr) minmax(120px, 1fr) minmax(110px, .8fr) minmax(160px, 1.1fr); gap: 12px; }
body.admin-app .device-filter-field { min-width: 0; }
body.admin-app .device-filter-field > label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
body.admin-app .device-filter-field > input, body.admin-app .device-filter-field > select { width: 100%; min-width: 0; height: 38px; padding: 7px 10px; }
body.admin-app .device-filter-search .search-box { min-width: 0; max-width: none; gap: 6px; }
body.admin-app .device-filter-search input { height: 38px; padding: 7px 10px; }
body.admin-app .device-filter-search button { padding: 7px 12px; }
body.admin-app .device-record-list { min-width: 0; }
body.admin-app .device-record-list #device-table { min-width: 0; width: 100%; border-collapse: separate; border-spacing: 0 10px; table-layout: fixed; background: transparent; }
body.admin-app .device-record-list #device-table .device-record-main > td { padding: 0; border: 0; width: auto; }
body.admin-app .device-record-card { border: 1px solid var(--record-line); border-radius: 11px; background: var(--surface); box-shadow: 0 2px 5px rgb(0 0 0 / 4%); overflow: hidden; }
body.admin-app .device-record-header { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; padding: 11px 16px; background: var(--surface-soft); border-bottom: 1px solid var(--line); }
body.admin-app .device-record-facts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px 16px; padding: 12px 16px; }
body.admin-app .device-record-facts dt { font-size: 11px; color: var(--muted); }
body.admin-app .device-record-facts dd { margin: 4px 0 0; font-size: 13px; color: var(--ink-strong); overflow-wrap: anywhere; }
:root { --ink-strong: var(--ink); --record-line: var(--line); --surface-soft: var(--wash); }
.device-page-header h1 { margin: 0; font-size: clamp(23px,4vw,30px); line-height: 1.3; }
body.admin-app .device-workspace .stats-cards { grid-template-columns: repeat(3,minmax(0,1fr)); }
body.admin-app .stat-card { background: var(--surface); border: solid 1px var(--line); }
body.admin-app .stat-value { color: var(--ink); }
body.admin-app .stat-label { color: var(--muted); }
body.admin-app .device-filter-grid { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
body.admin-app .device-filter-search .search-box { display: flex; }
body.admin-app .device-filter-search .search-box input { flex: 1 1 0; min-width: 0; }
.public-button, .device-filter-search button, .device-filter-field input {
  min-height: 38px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 7px;
  font: inherit; font-size: 13px; color: var(--ink); background: var(--surface);
}
.public-button, .device-filter-search button { cursor: pointer; white-space: nowrap; }
.public-button:hover, .device-filter-search button:hover { background: var(--wash); }
body.admin-app .device-record-facts { grid-template-columns: repeat(3,minmax(0,1fr)); margin: 0; }
.device-record-header h3 { margin: 0; font-size: 15px; }
.footer { display: grid; place-items: center; min-height: 56px; padding: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; text-align: center; }
.footer a { text-underline-offset: 3px; }
@media (max-width: 600px) {
  .topbar-content, .workspace { width: calc(100% - 32px); }
  .topbar-content { min-height: 56px; }
  .workspace { padding-block: 28px 36px; }
  body.admin-app .device-workspace .stat-card { gap: 6px; flex-direction: column; align-items: flex-start; padding: 10px; }
  .device-workspace .stat-icon { width: 32px; height: 32px; font-size: 16px; }
  .device-workspace .stat-value { font-size: 19px; }
  body.admin-app .device-filter-grid { grid-template-columns: 1fr; }
}
