:root {
  color-scheme: light;
  --ink: #182b39;
  --muted: #4f6573;
  --canvas: #f2f6f8;
  --line: #d9e4e9;
  --surface: #fff;
  --accent: #08776c;
  --accent-hover: #056358;
  --rail: #112637;
  font: 15px/1.55 system-ui, "Noto Sans JP", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.layout { min-height: 100vh; display: flex; }
.sidebar {
  position: sticky; top: 0; width: 232px; flex: 0 0 232px; height: 100vh;
  height: 100dvh; overflow: auto; padding: 26px 16px;
  color: #e4edf3; background: var(--rail);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; font-size: 1.12rem; font-weight: 750; }
.brand small { display: block; color: #b4c8d3; font-size: .76rem; font-weight: 500; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #bbede3; color: #125346; }
.sidebar nav { border-top: 1px solid #354959; padding-top: 16px; display: grid; gap: 7px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; color: #dfebf1; background: transparent; border-color: transparent; }
.nav-item:hover { background: #203a4c; }
.nav-item[aria-current="page"] { background: #254657; border-color: #466877; color: #fff; }
.nav-icon { width: 1.25rem; text-align: center; color: #a4ded3; font-size: 1.15rem; line-height: 1; }
.workspace { flex: 1; min-width: 0; }
.topbar { min-height: 72px; padding: 12px clamp(16px, 3vw, 42px); display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-title { display: flex; align-items: center; gap: 12px; }
.topbar h1 { margin: 0; font-size: clamp(1rem, 2.6vw, 1.2rem); }
.menu-toggle { display: none; }
main { width: min(100%, 1330px); margin: auto; padding: clamp(16px, 3.25vw, 44px); }
h2 { margin: 0 0 14px; font-size: clamp(1.3rem, 3vw, 1.7rem); letter-spacing: -.02em; }
h3 { margin: 18px 0 10px; font-size: 1.05rem; }
.panel, #login { background: var(--surface); padding: clamp(15px, 3vw, 28px); border: 1px solid var(--line); border-radius: 14px; }
#login { width: min(100%, 440px); margin: 55px auto 0; }
button { font: inherit; font-weight: 650; color: #fff; background: var(--accent); border: 1px solid transparent; padding: 8px 14px; min-height: 40px; border-radius: 8px; cursor: pointer; }
button:hover { background: var(--accent-hover); }
button:disabled { opacity: .6; cursor: default; }
.secondary { color: #135e56; background: var(--surface); border-color: #adc4c9; }
.secondary:hover { background: #e8f5f2; }
:focus-visible { outline: 3px solid #208eae; outline-offset: 3px; }
.table { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; text-align: left; border-collapse: collapse; font-variant-numeric: tabular-nums; }
#contracts { min-width: 650px; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--line); }
th { font-size: .85rem; color: #344f5d; background: #edf4f6; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f6fafb; }
#contracts td:last-child { width: 1%; white-space: nowrap; }
#status { margin: 0 0 14px; background: #fff7e4; color: #71480d; border: 1px solid #eedaa7; border-radius: 8px; padding: 9px 12px; }
#status:empty { display: none; }
.section-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-heading h2, .section-heading h3 { margin: 0; }
.metrics { margin: 0 0 18px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.metrics div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 15px; }
.metrics dt { font-size: .83rem; color: var(--muted); }
.metrics dd { margin: 2px 0 0; font-weight: 750; font-size: clamp(1.4rem, 3vw, 2.15rem); font-variant-numeric: tabular-nums; }
.back { margin-bottom: 16px; }
#detail-contract { color: var(--muted); font-variant-numeric: tabular-nums; }
form, #issued-code { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 12px 0 20px; }
label { display: grid; gap: 5px; font-weight: 650; min-width: 0; }
input, select { max-width: 100%; font: inherit; font-weight: 400; color: inherit; padding: 8px 10px; min-height: 40px; border: 1px solid #94acb2; border-radius: 7px; background: var(--surface); }
.form-screen form { display: grid; justify-items: start; max-width: 480px; }
.form-screen label { width: 100%; }
#key-code { width: min(100%, 29rem); font-family: monospace; }
#device-add { border-top: 1px solid var(--line); margin-top: 20px; }
@media (max-width: 720px) {
  .layout { display: flex; flex-direction: column; }
  .sidebar { display: none; position: fixed; z-index: 2; top: 60px; left: 0; width: min(232px, 85vw); height: calc(100dvh - 60px); padding: 14px 16px; box-shadow: 12px 0 30px #11263726; }
  .sidebar.is-open { display: block; }
  .brand { padding-bottom: 10px; }
  .sidebar nav { padding-top: 8px; }
  .menu-toggle { display: inline-block; }
  .topbar { position: sticky; z-index: 3; top: 0; min-height: 60px; }
  .metrics { gap: 6px; }
  .metrics div { padding: 9px; }
}

.checkbox-label { display: flex; align-items: center; gap: 7px; min-height: 40px; }
.checkbox-label input { min-height: auto; }
.device-actions { display: flex; flex-wrap: wrap; gap: 7px; }
