:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17201c;
  background: #f4f6f5;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input { font: inherit; letter-spacing: 0; }
button { min-height: 42px; border: 1px solid #173e31; border-radius: 6px; padding: 0 16px; color: white; background: #173e31; cursor: pointer; font-weight: 650; }
button:hover { background: #0e2f25; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid #e8b44b; outline-offset: 2px; }
button.secondary { color: #17201c; background: white; border-color: #bdc8c3; }
button.secondary:hover { background: #edf1ef; }
button.danger { color: #8e2626; background: white; border-color: #e0b4b4; }
button.danger:hover { background: #fff0f0; }
button:disabled { cursor: not-allowed; opacity: .45; }
input { width: 100%; min-height: 44px; margin-top: 7px; border: 1px solid #aebbb5; border-radius: 6px; padding: 9px 11px; background: white; }
label { display: block; font-size: .88rem; font-weight: 650; color: #34423c; }
h1 { margin: 0; font-size: 1.45rem; line-height: 1.25; letter-spacing: 0; }
p { line-height: 1.55; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #edf1ef; }
.auth-panel { width: min(100%, 390px); padding: 28px; border: 1px solid #d1d9d5; border-radius: 8px; background: white; box-shadow: 0 12px 35px rgba(30, 45, 38, .08); }
.setup-panel { width: min(100%, 460px); }
.brand-mark, .brand-inline { display: inline-grid; place-items: center; background: #173e31; color: #fff; font-weight: 800; }
.brand-mark { width: 42px; height: 42px; border-radius: 7px; margin-bottom: 18px; }
.brand-inline { width: 30px; height: 30px; border-radius: 5px; margin-right: 10px; font-size: .78rem; }
.muted { margin: 7px 0 22px; color: #68766f; }
.stack { display: grid; gap: 17px; }
.stack.compact { margin-top: 14px; }
.error, .notice { padding: 10px 12px; border-radius: 5px; font-size: .9rem; }
.error { color: #8e1c1c; background: #fff0f0; border: 1px solid #f0b9b9; }
.notice { color: #5c430d; background: #fff8e6; border: 1px solid #ecd294; }
details { margin-top: 18px; border-top: 1px solid #e1e6e3; padding-top: 15px; }
summary { cursor: pointer; color: #38594c; }
.qr { display: block; width: 230px; max-width: 100%; aspect-ratio: 1; margin: 18px auto; border: 1px solid #d8dfdc; }
.secret-code { display: grid; gap: 5px; padding: 10px; background: #f5f7f6; overflow-wrap: anywhere; }
.secret-code span { color: #68766f; font-size: .78rem; }
.recovery-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 18px 0; }
.recovery-grid code { padding: 9px; border: 1px solid #d8dfdc; border-radius: 4px; background: #f7f9f8; text-align: center; }
.topbar { height: 60px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(16px, 4vw, 44px); border-bottom: 1px solid #d6ded9; background: white; }
.topbar > div { display: flex; align-items: center; }
.topbar button { min-height: 36px; }
.workspace { width: min(1320px, calc(100% - 32px)); margin: 30px auto; }
.page-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 16px; }
.page-heading p { margin: 5px 0 0; color: #6c7872; }
.count { border: 1px solid #c9d3ce; border-radius: 5px; padding: 7px 10px; background: white; font-variant-numeric: tabular-nums; }
.table-shell { overflow-x: auto; border: 1px solid #d2dad6; border-radius: 7px; background: white; }
table { width: 100%; border-collapse: collapse; min-width: 1280px; table-layout: fixed; }
th, td { padding: 13px 14px; border-bottom: 1px solid #e4e9e6; text-align: left; vertical-align: middle; font-size: .9rem; }
th { color: #59675f; background: #f6f8f7; font-size: .78rem; text-transform: uppercase; }
th:nth-child(1), td:nth-child(1) { width: 190px; }
th:nth-child(2), td:nth-child(2) { width: 120px; }
th:nth-child(3), td:nth-child(3) { width: 105px; }
th:nth-child(4), td:nth-child(4), th:nth-child(5), td:nth-child(5) { width: 155px; }
th:nth-child(6), td:nth-child(6) { width: 95px; }
th:nth-child(7), td:nth-child(7) { width: 145px; }
th:nth-child(8), td:nth-child(8) { width: 315px; }
tbody tr:last-child td { border-bottom: 0; }
.slot-id { display: block; margin-top: 3px; color: #7d8983; font-size: .75rem; }
.status { display: inline-flex; align-items: center; min-height: 26px; border-radius: 999px; padding: 2px 9px; background: #edf0ef; color: #45534c; font-size: .78rem; white-space: nowrap; }
.status-ready { background: #e4f5eb; color: #17623e; }
.status-qr, .status-authenticated, .status-initializing, .status-recovering { background: #fff4d8; color: #71520b; }
.status-disconnected, .status-manual_attention { background: #fde9e9; color: #8e2626; }
.name-control { display: flex; align-items: center; gap: 6px; }
.name-control input { min-width: 100px; margin: 0; min-height: 36px; }
.name-control button, .row-actions button { min-height: 34px; padding: 0 10px; font-size: .78rem; white-space: nowrap; }
.key-control { display: grid; gap: 7px; }
.key-control code { color: #516158; font-size: .76rem; overflow-wrap: anywhere; }
.row-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: min(360px, calc(100% - 40px)); margin: 0; padding: 11px 14px; border: 1px solid #91b5a4; border-radius: 6px; background: #e8f5ef; color: #174e35; box-shadow: 0 8px 24px rgba(20, 40, 30, .16); }
.toast-error { border-color: #dda6a6; background: #fff0f0; color: #8e2626; }
dialog { width: min(420px, calc(100% - 24px)); border: 1px solid #ccd6d1; border-radius: 8px; padding: 24px; color: #17201c; background: white; }
dialog::backdrop { background: rgba(17, 27, 22, .55); }
dialog h2 { margin: 0; font-size: 1.2rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
#qr-dialog .qr { width: 300px; margin: 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 600px) {
  .auth-shell { padding: 12px; }
  .auth-panel { padding: 22px; }
  .recovery-grid { grid-template-columns: 1fr; }
  .workspace { width: min(100% - 20px, 1320px); margin-top: 20px; }
  .page-heading { align-items: start; }
  .table-shell { overflow: visible; border: 0; background: transparent; }
  table, tbody, tr, td { display: block; width: 100%; min-width: 0; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  tbody { display: grid; gap: 12px; }
  tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid #d2dad6; border-radius: 7px; background: white; overflow: hidden; }
  tbody tr:last-child td { border-bottom: 1px solid #e4e9e6; }
  td { min-width: 0; padding: 30px 12px 12px; border-bottom: 1px solid #e4e9e6; }
  td::before { content: attr(data-label); display: block; position: absolute; margin-top: -20px; color: #66736c; font-size: .7rem; font-weight: 700; text-transform: uppercase; }
  td[data-label="名稱"], td[data-label="連線"], td[data-label="API Key"] { grid-column: 1 / -1; }
  td[data-label="名稱"] { padding-top: 34px; }
  td[data-label="API Key"] { border-bottom: 0; }
  .name-control input { min-width: 0; }
}
