/* Enterprise BtoB look: white / navy / dark gray / light gray. Accent colour only where it carries meaning. */
:root {
  --navy: #14315c;
  --navy-dark: #0d2544;
  --navy-light: #2a4d80;
  --ink: #1f2733;
  --gray-700: #4a5462;
  --gray-500: #6b7683;
  --gray-300: #c9d0d8;
  --gray-200: #dde2e8;
  --gray-100: #eef1f5;
  --gray-50: #f6f8fa;
  --white: #fff;
  --high: #a3242b;
  --high-bg: #fbeaea;
  --medium: #8a5a12;
  --medium-bg: #fdf3e2;
  --low: #2c6048;
  --low-bg: #e9f3ee;
  --info-bg: #eaf0f8;
  --line: #d7dde5;
  --font: 'Hiragino Kaku Gothic ProN', 'Yu Gothic', Meiryo, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--gray-50);
  font-size: 13px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy); }

/* ---- persistent prototype banner (thin, always visible, not alarming) ---- */
.proto-banner {
  position: sticky; top: 0; z-index: 40;
  background: var(--navy-dark); color: #dfe6f0;
  font-size: 11px; letter-spacing: .08em; text-align: center;
  padding: 5px 12px; border-bottom: 1px solid #06182e;
}
.proto-banner strong { color: #fff; font-weight: 600; }
.proto-banner span { opacity: .85; }

.app-header {
  position: sticky; top: 26px; z-index: 30;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 52px; border-bottom: 1px solid var(--navy-dark);
}
.app-title { font-size: 15px; font-weight: 600; letter-spacing: .02em; }
.app-title small { display: block; font-size: 10px; font-weight: 400; opacity: .7; letter-spacing: .06em; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.demo-switch { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.demo-switch label { opacity: .8; }
.demo-switch select {
  font-family: var(--font); font-size: 12px; padding: 4px 8px; min-width: 260px;
  border: 1px solid var(--navy-light); border-radius: 2px; background: #fff; color: var(--ink);
}
.btn-reset {
  font-family: var(--font); font-size: 11px; padding: 5px 10px; cursor: pointer;
  background: transparent; color: #dfe6f0; border: 1px solid var(--navy-light); border-radius: 2px;
}
.btn-reset:hover { background: var(--navy-light); }

.app-nav {
  position: sticky; top: 78px; z-index: 20;
  background: #fff; border-bottom: 1px solid var(--line); padding: 0 20px; display: flex; gap: 2px;
}
.app-nav a {
  padding: 10px 14px; font-size: 12.5px; color: var(--gray-700); text-decoration: none;
  border-bottom: 2px solid transparent;
}
.app-nav a:hover { color: var(--navy); background: var(--gray-50); }
.app-nav a.active { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }
.nav-badge {
  display: inline-block; margin-left: 6px; background: var(--navy); color: #fff;
  border-radius: 9px; font-size: 10px; padding: 0 6px; line-height: 15px;
}

main { padding: 18px 20px 40px; max-width: 1400px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 18px; margin: 0; font-weight: 600; }
.page-head .sub { font-size: 11.5px; color: var(--gray-500); }
.page-head .spacer { margin-left: auto; }

.card { background: #fff; border: 1px solid var(--line); border-radius: 3px; margin-bottom: 14px; }
.card > h2 {
  font-size: 12.5px; margin: 0; padding: 9px 14px; border-bottom: 1px solid var(--line);
  background: var(--gray-50); font-weight: 600; letter-spacing: .02em; display: flex; align-items: center; gap: 8px;
}
.card > h2 .note { font-weight: 400; color: var(--gray-500); font-size: 11px; }
.card-body { padding: 14px; }
.card-body.tight { padding: 0; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }
/* Tablet: collapse every grid (including inline grid-template-columns set in screens) to 2 columns. */
@media (max-width: 1024px) { main .grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } }

.kpi { background: #fff; border: 1px solid var(--line); border-radius: 3px; padding: 11px 13px; cursor: default; }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: var(--navy-light); background: var(--gray-50); }
.kpi .k-label { font-size: 11px; color: var(--gray-500); display: flex; align-items: baseline; gap: 5px; }
.kpi .k-value { font-size: 22px; font-weight: 600; letter-spacing: -.01em; margin-top: 3px; }
.kpi .k-value .unit { font-size: 12px; font-weight: 400; color: var(--gray-500); margin-left: 3px; }
.kpi .k-note { font-size: 10.5px; color: var(--gray-500); margin-top: 2px; }
.kpi.alert .k-value { color: var(--high); }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--gray-200); vertical-align: top; }
th { background: var(--gray-50); font-weight: 600; color: var(--gray-700); font-size: 11px; white-space: nowrap; }
tbody tr:hover { background: var(--gray-50); }
tr.row-link { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap, th.nowrap { white-space: nowrap; }
.table-empty { padding: 22px; text-align: center; color: var(--gray-500); font-size: 12px; }

.badge {
  display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 2px;
  border: 1px solid var(--gray-300); background: var(--gray-100); color: var(--gray-700); white-space: nowrap;
}
.badge.high { background: var(--high-bg); border-color: #e2b6b8; color: var(--high); font-weight: 600; }
.badge.medium { background: var(--medium-bg); border-color: #e6cb98; color: var(--medium); }
.badge.low { background: var(--low-bg); border-color: #b7d4c6; color: var(--low); }
.badge.navy { background: var(--info-bg); border-color: #b8c8de; color: var(--navy); }
.badge.solid { background: var(--navy); border-color: var(--navy); color: #fff; }
.badge.muted { opacity: .75; }
.badge + .badge { margin-left: 4px; }

.btn {
  font-family: var(--font); font-size: 12px; padding: 6px 13px; border-radius: 2px; cursor: pointer;
  border: 1px solid var(--gray-300); background: #fff; color: var(--ink);
}
.btn:hover:not(:disabled) { background: var(--gray-100); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--navy-light); }
.btn.danger { color: var(--high); border-color: #e2b6b8; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label.field { display: block; margin-bottom: 12px; }
label.field > span.lbl { display: block; font-size: 11.5px; color: var(--gray-700); margin-bottom: 3px; font-weight: 600; }
label.field > span.hint { display: block; font-size: 10.5px; color: var(--gray-500); font-weight: 400; }
input[type=text], input[type=number], input[type=date], select, textarea {
  font-family: var(--font); font-size: 12.5px; padding: 5px 8px; width: 100%;
  border: 1px solid var(--gray-300); border-radius: 2px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b8c8de; outline-offset: -1px; }
textarea { min-height: 62px; resize: vertical; }
.yn-group { display: flex; gap: 6px; }
.yn-group button {
  font-family: var(--font); font-size: 12px; padding: 4px 12px; cursor: pointer;
  border: 1px solid var(--gray-300); background: #fff; border-radius: 2px; color: var(--gray-700);
}
.yn-group button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.checks label { font-size: 12px; display: flex; align-items: center; gap: 4px; font-weight: 400; }
.checks input { width: auto; }

.form-section { border-top: 1px solid var(--gray-200); padding-top: 12px; margin-top: 4px; }
.form-section > h3 { font-size: 12px; margin: 0 0 10px; color: var(--navy); font-weight: 600; }
.sticky-side { position: sticky; top: 130px; }

.msg { padding: 8px 11px; border-radius: 2px; font-size: 11.5px; margin-bottom: 8px; border: 1px solid; }
.msg.blocking { background: var(--high-bg); border-color: #e2b6b8; color: #7a1b21; }
.msg.warning { background: var(--medium-bg); border-color: #e6cb98; color: #6f480e; }
.msg.info { background: var(--info-bg); border-color: #b8c8de; color: var(--navy-dark); }
.msg.ok { background: var(--low-bg); border-color: #b7d4c6; color: var(--low); }
.msg .rule { font-weight: 600; margin-right: 5px; }

dl.kv { margin: 0; display: grid; grid-template-columns: 190px 1fr; gap: 0; font-size: 12px; }
dl.kv dt { color: var(--gray-500); padding: 5px 0; border-bottom: 1px solid var(--gray-100); }
dl.kv dd { margin: 0; padding: 5px 0; border-bottom: 1px solid var(--gray-100); }
@media (max-width: 768px) { dl.kv { grid-template-columns: 1fr; } dl.kv dt { padding-bottom: 0; border-bottom: none; } }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 12px 18px; border-left: 1px solid var(--gray-200); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ''; position: absolute; left: -4px; top: 5px; width: 7px; height: 7px;
  background: var(--navy); border-radius: 50%;
}
.timeline .t-time { font-size: 10.5px; color: var(--gray-500); font-variant-numeric: tabular-nums; }
.timeline .t-type { font-weight: 600; font-size: 12px; }
.timeline .t-body { font-size: 11.5px; color: var(--gray-700); }
.timeline .t-reason { font-size: 11.5px; color: var(--high); }

.bar-row { display: grid; grid-template-columns: 150px 1fr 90px; align-items: center; gap: 8px; margin-bottom: 5px; font-size: 11.5px; }
.bar-track { background: var(--gray-100); height: 14px; border-radius: 2px; overflow: hidden; }
.bar-fill { background: var(--navy); height: 100%; }
.bar-fill.high { background: var(--high); }
.bar-fill.medium { background: #c08a2a; }
.bar-fill.low { background: #4b8a6d; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--gray-700); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 0; flex-wrap: wrap; }
.tabs button {
  font-family: var(--font); font-size: 12px; padding: 8px 14px; cursor: pointer;
  background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--gray-700);
}
.tabs button.on { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }
.tabs button:hover { background: var(--gray-50); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.filters label { font-size: 11px; color: var(--gray-500); }
.filters select, .filters input { min-width: 130px; }

.rule-item { border-bottom: 1px solid var(--gray-200); }
.rule-item:last-child { border-bottom: none; }
.rule-head {
  display: flex; gap: 10px; align-items: center; padding: 9px 14px; cursor: pointer; font-size: 12.5px;
}
.rule-head:hover { background: var(--gray-50); }
.rule-head .rid { font-weight: 600; color: var(--navy); min-width: 52px; }
.rule-head .rtrigger { color: var(--gray-500); font-size: 11.5px; margin-left: auto; text-align: right; }
.rule-detail { padding: 4px 14px 14px 14px; background: var(--gray-50); }

footer.disclaimer {
  border-top: 1px solid var(--line); background: #fff; padding: 14px 20px; font-size: 10.5px;
  color: var(--gray-500); line-height: 1.7;
}
footer.disclaimer strong { color: var(--gray-700); }
.muted { color: var(--gray-500); }
.small { font-size: 11px; }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.mb0 { margin-bottom: 0; }
.hr { border-top: 1px solid var(--gray-200); margin: 10px 0; }

/* ============================================================================
   Responsive support (Concept Prototype — minimal, layout/CSS only).
   Desktop layout is unchanged; the rules below apply to tablet and phone only.
   ========================================================================== */

/* Mobile navigation toggle: hidden on desktop, shown at <=768px. */
.nav-toggle { display: none; }

@media (max-width: 768px) {
  /* --- 1. remove horizontal overflow --- */
  html, body { max-width: 100%; overflow-x: hidden; }
  body { font-size: 14px; }
  main { padding: 14px 12px 32px; max-width: 100%; }
  .page-head h1 { font-size: 17px; }

  /* Sticky positioning is dropped on small screens: the header wraps to a
     variable height, so fixed sticky offsets would overlap the content. */
  .proto-banner, .app-header, .app-nav { position: static; }
  .proto-banner { font-size: 10px; letter-spacing: .04em; line-height: 1.4; padding: 5px 10px; }

  /* --- 2. header: stack title / role switcher --- */
  .app-header { height: auto; flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .app-title { font-size: 14px; }
  .header-right { width: 100%; margin-left: 0; gap: 8px; }
  .demo-switch { flex: 1; gap: 5px; }
  .demo-switch select { min-width: 0; width: 100%; font-size: 16px; }
  .btn-reset { font-size: 12px; padding: 7px 10px; }
  .nav-toggle {
    display: inline-flex; align-items: center; gap: 6px; margin-left: auto;
    font-family: var(--font); font-size: 13px; padding: 6px 11px; cursor: pointer;
    background: transparent; color: #fff; border: 1px solid var(--navy-light); border-radius: 2px;
  }

  /* --- 3. navigation: collapsible --- */
  .app-nav { display: none; flex-direction: column; padding: 0; gap: 0; }
  .app-nav.open { display: flex; }
  .app-nav a { padding: 11px 14px; border-bottom: 1px solid var(--gray-200); border-left: 2px solid transparent; font-size: 14px; }
  .app-nav a.active { border-bottom-color: var(--gray-200); border-left-color: var(--navy); background: var(--gray-50); }
  .app-nav > span { margin-left: 0 !important; padding: 9px 14px; font-size: 11px; }

  /* --- 4. grids: gap tightened here; column count is set by the blocks below --- */
  main .grid { gap: 12px; }
  .sticky-side { position: static; }

  /* --- 5. tables: horizontal scroll, no column removal --- */
  .card-body, .card-body.tight { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card-body table, main > table { min-width: 820px; }
  /* Give the name/title column a floor so rows do not stretch vertically. */
  .card-body table td:nth-child(2), .card-body table th:nth-child(2) { min-width: 150px; }
  th, td { padding: 7px 8px; }

  /* --- 6. forms: single column, full-width controls --- */
  input[type=text], input[type=number], input[type=date], select, textarea { font-size: 16px; width: 100%; }
  .yn-group { flex-wrap: wrap; }
  .yn-group button { font-size: 14px; padding: 7px 14px; }
  .checks { gap: 6px 12px; }
  .checks label { font-size: 13px; }
  .filters { gap: 10px; }
  .filters label { width: 100%; }
  .filters select, .filters input { min-width: 0; width: 100%; }

  /* --- 7. buttons: tappable, wrap instead of squeezing --- */
  .btn { font-size: 14px; padding: 9px 14px; }
  .btn-row { gap: 8px; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .tabs button { font-size: 13px; padding: 9px 12px; white-space: nowrap; }

  /* --- 8. KPI cards and charts fit the parent width --- */
  .kpi .k-value { font-size: 21px; }
  .bar-row { grid-template-columns: 108px 1fr 66px; gap: 6px; font-size: 11.5px; }

  /* --- 9. misc --- */
  .rule-head { flex-wrap: wrap; gap: 4px 10px; }
  .rule-head .rtrigger { margin-left: 0; text-align: left; width: 100%; }
  footer.disclaimer { padding: 12px 12px 22px; }
}

/* Phone: a single column for every grid (including inline grid-template-columns). */
@media (max-width: 640px) { main .grid { grid-template-columns: 1fr !important; } }

@media (max-width: 480px) {
  .page-head { gap: 6px; }
  .page-head .spacer { display: none; }
  .btn-row .btn { flex: 1 1 auto; }
  .card > h2 { flex-wrap: wrap; gap: 4px; }
  .kpi .k-value { font-size: 19px; }
}
