/* Admin Console shell: same structure, tokens and fonts as the Dealer System (mock-ui theme.css/fonts.css). */
:root { --header-height: 68px; --sidebar-width: 232px; font-family: "Host Grotesk", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif; font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--canvas); }
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.hidden { display: none !important; }

/* Shell */
.workspace-header { position: fixed; inset: 0 0 auto; height: var(--header-height); display: grid; grid-template-columns: max-content minmax(0, 1fr) auto; align-items: center; gap: 24px; padding: 0 24px 0 0; background: var(--surface); border-bottom: 1px solid var(--line); z-index: 30; }
.brand { display: flex; align-items: center; gap: 9px; padding-left: 24px; color: var(--ink); min-width: 0; }
.brand-mark { width: 28px; height: 28px; display: block; flex: none; --logo-line: var(--ink); --logo-surface: var(--surface); --logo-tank: var(--surface-subtle); --logo-accent: var(--ink); }
.brand-name { font-size: 20px; line-height: 28px; font-weight: 650; white-space: nowrap; }
.brand-badge { font-size: 12px; font-weight: 650; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.header-actions { display: flex; gap: 12px; align-items: center; }
.theme-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.admin-identity { font-size: 13px; color: var(--muted); }
.sidebar { position: fixed; inset: var(--header-height) auto 0 0; width: var(--sidebar-width); padding: 20px 18px; background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; z-index: 20; }
.workspace-label { margin: 0 10px 10px; font-size: 12px; font-weight: 650; letter-spacing: .08em; color: var(--muted); }
.sidebar nav { display: grid; gap: 6px; }
.sidebar nav a { display: flex; align-items: center; min-height: 44px; padding: 10px 12px; font-size: 16px; font-weight: 500; color: var(--muted); }
.sidebar nav a:hover { background: var(--surface-subtle); }
.sidebar nav a[aria-current=page] { background: var(--accent-soft); box-shadow: inset 3px 0 var(--ink); color: var(--ink); font-weight: 650; }
.shell { position: fixed; inset: var(--header-height) 0 0 var(--sidebar-width); overflow: auto; overscroll-behavior: contain; }
main { padding: 24px 32px 48px; }
main:focus { outline: none; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
h1 { font-size: 28px; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: .08em; margin-bottom: 4px; }
.muted { color: var(--muted); font-size: 13px; }

/* Controls */
input, select { width: 100%; min-height: 40px; border: 1px solid var(--control-line); border-radius: 6px; padding: 8px 12px; background: var(--surface); }
select { width: auto; }
input[type=checkbox] { width: auto; min-height: 0; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.primary, .secondary, .danger { min-height: 40px; border-radius: 6px; padding: 8px 14px; font-weight: 650; border: 1px solid var(--control-line); background: var(--surface); }
.primary { background: var(--primary-bg); color: var(--primary-text); border-color: var(--primary-bg); }
.danger { background: var(--red); color: var(--surface); border-color: var(--red); }
.primary:disabled, .secondary:disabled, .danger:disabled { cursor: not-allowed; opacity: .45; }
.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.icon { border: 0; background: transparent; font-size: 28px; line-height: 1; }
.error { min-height: 20px; color: var(--red); font-size: 13px; margin: 8px 0; white-space: pre-wrap; }
.warning { padding: 10px 12px; border-radius: 6px; background: var(--amber-soft); color: var(--amber); font-size: 13px; margin: 8px 0; }
.notice { padding: 10px 14px; margin-bottom: 12px; border-radius: 6px; background: var(--amber-soft); color: var(--amber); }
.field { display: block; margin-top: 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select { margin-top: 6px; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 14px; font-size: 14px; }
.password-row { display: flex; gap: 8px; margin-top: 6px; align-items: center; }
.password-row input { flex: 1; margin: 0; font-family: "SFMono-Regular", Consolas, monospace; }
.password-row button { flex: none; }
.hint { margin-top: 6px; color: var(--amber); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 60; max-width: min(480px, 90vw); padding: 12px 16px; border-radius: 8px; background: var(--primary-bg); color: var(--primary-text); box-shadow: var(--shadow); }

/* Tables and panels */
.viewer, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; }
.panel { padding: 20px; margin-bottom: 16px; overflow: visible; }
.panel h3 { font-size: 17px; margin-bottom: 8px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.search { flex: 1; max-width: 560px; }
.search span { display: block; font-size: 12px; font-weight: 650; color: var(--muted); margin-bottom: 6px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { color: var(--muted); background: var(--surface-subtle); font-size: 13px; font-weight: 650; text-align: left; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.logwatch-table { table-layout: fixed; }
.logwatch-table th:nth-child(1) { width: 172px; } .logwatch-table th:nth-child(2) { width: 20%; } .logwatch-table th:nth-child(3) { width: 110px; } .logwatch-table th:nth-child(4) { width: 170px; } .logwatch-table th:nth-child(5) { width: 180px; }
.logwatch-table td:nth-child(3), .logwatch-table td:nth-child(4) { overflow-wrap: anywhere; }
.sort { border: 0; padding: 0; background: transparent; font: inherit; }
.entry { cursor: pointer; }
.entry:hover { background: var(--surface-subtle); }
.entry.selected { background: var(--accent-soft); box-shadow: inset 3px 0 var(--ink); }
.entry:focus { outline: 2px solid var(--focus); outline-offset: -2px; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }
.outcome strong { display: block; font-size: 13px; } .outcome span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.payload { overflow-wrap: anywhere; white-space: normal; }
.badge { display: inline-block; margin-right: 5px; padding: 2px 5px; border-radius: 4px; background: var(--surface-subtle); font: 10px "SFMono-Regular", monospace; }
.live { font-size: 13px; font-weight: 650; padding: 6px 11px; border-radius: 999px; background: var(--green-soft); color: var(--success); }
.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 7px; }
.live.reconnecting { background: var(--amber-soft); color: var(--amber); }
.load-more { padding: 16px; text-align: center; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.new-messages { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 9px; background: var(--green-soft); color: var(--success); font-weight: 650; }
.status-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 650; }
.status-badge.active { background: var(--green-soft); color: var(--success); }
.status-badge.inactive { background: var(--red-soft); color: var(--red); }
.dealer-code { font-weight: 650; font-variant-numeric: tabular-nums; }
td .dealer-code { text-decoration: underline; text-underline-offset: 3px; }
.dealer-table th:first-child { width: 40%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-block; margin-bottom: 12px; color: var(--muted); }
.detail-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.detail-head h2 { font-size: 24px; }
.dealer-form { max-width: 520px; }
.dealer-form .form-actions { justify-content: flex-start; }
.danger-zone { border-color: var(--red); }
.danger-zone .danger { margin-top: 12px; }
.operator-fields { border: 1px solid var(--line); border-radius: 6px; margin: 14px 0 0; padding: 4px 14px 14px; }
.operator-fields legend { font-size: 13px; font-weight: 650; padding: 0 6px; }

/* Drawer and dialogs */
.drawer { position: fixed; inset: var(--header-height) 0 0 auto; width: min(520px, 94vw); z-index: 40; overflow-y: auto; background: var(--raised); border-left: 1px solid var(--line); box-shadow: var(--shadow); padding: 24px; }
.drawer-head, .dialog-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 18px; }
.detail-section { padding: 16px 0; border-top: 1px solid var(--line); } .detail-section h3 { margin: 0 0 10px; font-size: 14px; }
.detail-section dl { display: grid; grid-template-columns: 135px 1fr; gap: 8px 12px; margin: 0; font-size: 13px; } .detail-section dt { color: var(--muted); } .detail-section dd { margin: 0; overflow-wrap: anywhere; }
.exact-payload { white-space: pre-wrap; overflow-wrap: anywhere; padding: 12px; border-radius: 6px; background: var(--surface-subtle); }
.export-dialog { width: min(620px, 94vw); border: 1px solid var(--line); border-radius: 10px; padding: 24px; background: var(--raised); color: var(--ink); box-shadow: var(--shadow); }
.export-dialog::backdrop { background: var(--backdrop); }
.export-dialog h2 { font-size: 20px; }
.export-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }
.export-status { min-height: 90px; padding: 12px; border-radius: 6px; background: var(--surface-subtle); white-space: pre-wrap; overflow-wrap: anywhere; }
.purge-panel { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.purge-panel .danger { margin-top: 12px; }
.purge-result { margin-top: 16px; padding: 14px; border-radius: 6px; background: var(--green-soft); color: var(--success); font-weight: 650; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Login */
.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 32px 20px; background: var(--canvas); }
.login-screen form { width: min(100%, 420px); background: var(--surface); padding: 36px; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 650; margin-bottom: 20px; }
.login-screen h2 { font-size: 28px; margin: 4px 0 20px; }
.login-screen label { display: block; margin: 14px 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.login-screen label input { margin-top: 6px; }
.login-screen button { width: 100%; margin-top: 8px; }

@media (max-width: 900px) {
  .workspace-header { grid-template-columns: 1fr auto; gap: 8px; padding-right: 12px; }
  .workspace-header > div:empty, .admin-identity, .theme-label { display: none; }
  .sidebar { position: static; width: auto; height: auto; padding: 8px 12px; margin-top: var(--header-height); border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { grid-auto-flow: column; justify-content: start; }
  .workspace-label { display: none; }
  .shell { position: static; }
  main { padding: 20px 14px; }
  .page-head, .toolbar { flex-direction: column; align-items: stretch; }
  .logwatch-table { min-width: 980px; }
}
:root[data-theme=dark] .primary { background: var(--ink); color: var(--canvas); border-color: var(--ink); }
.field select { display: block; min-width: 160px; }

/* Avatar menu (same as Dealer System) */
.user-control { position: relative; min-width: 0; max-width: 260px; }
#user-menu-toggle { display: flex; align-items: center; gap: 9px; min-height: 44px; padding: 4px 8px; border: 0; border-radius: 8px; background: transparent; text-align: left; }
#user-menu-toggle:hover, #user-menu-toggle[aria-expanded=true] { background: var(--surface-subtle); }
.avatar { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--green); border: 1px solid var(--line); font-size: 13px; }
.identity { min-width: 0; } .identity strong, .identity small { display: block; font-size: 12px; font-weight: 400; line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity small { color: var(--muted); }
#user-menu { position: absolute; right: 0; top: calc(100% + 12px); width: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 35; }
#user-menu[hidden] { display: none; }
#user-menu button { display: block; width: 100%; min-height: 44px; text-align: left; border: 0; background: transparent; border-radius: 6px; padding: 10px 14px; }
#user-menu button:hover { background: var(--surface-subtle); }
#user-menu #logout-action { border-top: 1px solid var(--line); border-radius: 0; color: var(--red); margin-top: 4px; }
.self-badge { margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--accent-soft); }
.danger-text { color: var(--red); }
.admin-table th:nth-child(5) { width: 320px; }
