:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #17212b;
  --muted: #5b6b7a;
  --line: #dde3e9;
  --brand: #0f5c63;
  --brand-ink: #ffffff;
  --brand-soft: #e3f1f2;
  --accent: #b45309;
  --danger: #b91c1c;
  --ok: #15803d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
small, .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ---------- 部品 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card > h2 { margin-bottom: 10px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #eef2f5; color: var(--muted); white-space: nowrap; }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.danger { background: #fee2e2; color: var(--danger); }
.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.sso { background: #dbeafe; color: #1d4ed8; }
.badge.form { background: #ffedd5; color: #9a3412; }
.badge.link { background: #ede9fe; color: #5b21b6; }
.notice { padding: 10px 12px; border-radius: 10px; background: #fef3c7; color: #78350f; font-size: 13px; }
.notice.error { background: #fee2e2; color: #7f1d1d; }
.notice.info { background: var(--brand-soft); color: #134e4a; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 14px; font-family: inherit; cursor: pointer; text-decoration: none; }
.btn { white-space: nowrap; }
.btn:hover { background: #f1f4f7; text-decoration: none; }
td > a.row { min-width: 200px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: #0c4a50; }
.btn.danger { color: var(--danger); border-color: #f1c4c4; }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; padding: 12px; font-size: 16px; }

input[type="text"], input[type="password"], input[type="date"], input[type="search"], input[type="number"], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #c7d0d9; border-radius: 10px; font-size: 15px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field + .field { margin-top: 10px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin: 0; flex: 1; min-width: 140px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid #edf0f3; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* ---------- ポータル（職員向け・スマホ） ---------- */
.portal { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.portal-head { background: var(--brand); color: var(--brand-ink); padding: 14px 16px 18px; }
.portal-head .title { font-size: 13px; opacity: 0.85; letter-spacing: 0.04em; }
.portal-head .who { font-size: 20px; font-weight: 700; margin-top: 2px; }
.portal-head .where { font-size: 13px; opacity: 0.92; margin-top: 2px; }
.portal-head .chips { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; background: rgba(255, 255, 255, 0.18); color: #fff; }
.portal-body { padding: 14px 14px 28px; flex: 1; }
.portal-body > * + * { margin-top: 14px; }
.section-title { font-size: 13px; color: var(--muted); font-weight: 600; margin: 4px 2px 8px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); color: var(--ink); text-align: center; min-height: 112px; }
.tile:hover { text-decoration: none; border-color: var(--brand); }
.tile .icon { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; font-weight: 700; }
.tile .name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.tile .badge { font-size: 10px; padding: 0 6px; }
.device-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 0 2px; }
.device-bar .btn { white-space: nowrap; }
.stack > input[type="hidden"] { display: none; margin: 0; }
.signin { max-width: 380px; margin: 0 auto; padding: 40px 18px; }
.signin .brand { text-align: center; margin-bottom: 20px; }
.signin .brand .mark { width: 56px; height: 56px; border-radius: 16px; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; }
.signin .brand h1 { margin-top: 10px; }
.signin input { font-size: 20px; padding: 12px; letter-spacing: 0.08em; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid #edf0f3; font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); width: 44px; flex: none; font-variant-numeric: tabular-nums; }
.preview-banner { background: #1e293b; color: #fff; padding: 8px 14px; font-size: 13px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.preview-banner a { color: #93c5fd; }
.preview-banner input[type="date"] { width: auto; padding: 3px 6px; font-size: 13px; }

/* ---------- 管理画面 ---------- */
.admin { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.admin-nav { background: #12222b; color: #cbd5e1; padding: 16px 10px; }
.admin-nav .logo { color: #fff; font-weight: 700; padding: 4px 10px 14px; font-size: 15px; }
.admin-nav .logo small { display: block; color: #94a3b8; font-weight: 400; font-size: 11px; }
.admin-nav a { display: block; padding: 8px 10px; border-radius: 8px; color: #cbd5e1; font-size: 14px; }
.admin-nav a:hover { background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.admin-nav a.active { background: var(--brand); color: #fff; }
.admin-nav .sep { height: 1px; background: rgba(255, 255, 255, 0.1); margin: 10px 6px; }
.admin-main { padding: 20px 24px 40px; min-width: 0; }
.admin-main > * + * { margin-top: 16px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px; align-items: start; }
.cols.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bar { height: 8px; border-radius: 999px; background: #e7ecf0; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); }

.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 14px; border-left: 1px solid var(--line); padding-left: 8px; }
.tree summary { cursor: pointer; padding: 3px 4px; border-radius: 6px; list-style: none; display: flex; gap: 6px; align-items: center; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: "▸"; color: var(--muted); width: 12px; flex: none; font-size: 11px; }
.tree details[open] > summary::before { content: "▾"; }
.tree .leaf { padding: 3px 4px 3px 22px; display: flex; gap: 6px; align-items: center; border-radius: 6px; }
.tree summary:hover, .tree .leaf:hover { background: #f1f4f7; }
.tree .current { background: var(--brand-soft); }
.tree .kind { font-size: 11px; color: var(--muted); }
.tree .count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tree a { color: var(--ink); }
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.app-icon { width: 32px; height: 32px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 15px; flex: none; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; font-size: 13px; color: var(--muted); }
details.more > summary { cursor: pointer; color: var(--brand); font-size: 13px; }
details.more[open] > summary { margin-bottom: 10px; }

@media (max-width: 860px) {
  .admin { grid-template-columns: 1fr; }
  .admin-nav { display: flex; gap: 4px; overflow-x: auto; padding: 8px; align-items: center; }
  .admin-nav .logo { padding: 4px 8px; white-space: nowrap; }
  .admin-nav .logo small, .admin-nav .sep { display: none; }
  .admin-nav a { white-space: nowrap; }
  .admin-main { padding: 14px 12px 32px; }
  .cols, .cols.even { grid-template-columns: 1fr; }
}
