/* EAライセンス認証 管理画面 */
:root {
  color-scheme: light;
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f8f9fb; --border: #e2e5ea; --border-strong: #c9ced6;
  --text: #1c1f24; --text-2: #4b5260; --muted: #737b88;
  --accent: #2a78d6; --accent-ink: #ffffff; --accent-soft: #e7f0fb;
  --nav: #16304f; --nav-hover: #22446c;
  /* 状態の色(意味が決まった色。必ず文字ラベルと一緒に使う) */
  --good: #12854a; --good-bg: #e3f5ea; --good-mark: #1baf7a;
  --warn: #8a5800; --warn-bg: #fff2cf; --warn-mark: #eda100;
  --bad: #b42318; --bad-bg: #fde8e6; --bad-mark: #e34948;
  --off: #4b5563; --off-bg: #eceef2; --off-mark: #9aa1ad;
  --none: #737b88; --none-bg: #f4f5f7; --none-mark: #d3d7de;
  --black: #1c1f24;
  --bar: #2a78d6; --bar-2: #a9c8ef;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121417; --surface: #1b1e23; --surface-2: #22262c; --border: #2e333b; --border-strong: #444b55;
    --text: #eceef1; --text-2: #c2c7d0; --muted: #8e96a3;
    --accent: #3987e5; --accent-ink: #ffffff; --accent-soft: #1d2f47;
    --nav: #0d1b2c; --nav-hover: #1a3150;
    --good: #5fd39a; --good-bg: #13321f; --good-mark: #199e70;
    --warn: #f4c35a; --warn-bg: #3a2c09; --warn-mark: #c98500;
    --bad: #ff8a80; --bad-bg: #3d1614; --bad-mark: #e66767;
    --off: #b8bfca; --off-bg: #2a2f36; --off-mark: #6b7380;
    --none: #8e96a3; --none-bg: #1f2328; --none-mark: #3b414a;
    --black: #000000;
    --bar: #3987e5; --bar-2: #2c4a70;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121417; --surface: #1b1e23; --surface-2: #22262c; --border: #2e333b; --border-strong: #444b55;
  --text: #eceef1; --text-2: #c2c7d0; --muted: #8e96a3;
  --accent: #3987e5; --accent-ink: #ffffff; --accent-soft: #1d2f47;
  --nav: #0d1b2c; --nav-hover: #1a3150;
  --good: #5fd39a; --good-bg: #13321f; --good-mark: #199e70;
  --warn: #f4c35a; --warn-bg: #3a2c09; --warn-mark: #c98500;
  --bad: #ff8a80; --bad-bg: #3d1614; --bad-mark: #e66767;
  --off: #b8bfca; --off-bg: #2a2f36; --off-mark: #6b7380;
  --none: #8e96a3; --none-bg: #1f2328; --none-mark: #3b414a;
  --black: #000000;
  --bar: #3987e5; --bar-2: #2c4a70;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55;
       font-family: -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ナビ */
.nav { background: var(--nav); color: #fff; display: flex; align-items: center; gap: 2px; padding: 0 16px;
       flex-wrap: wrap; position: sticky; top: 0; z-index: 20; }
.nav a, .nav button { color: #dfe7f1; padding: 13px 12px; font: inherit; background: none; border: 0; cursor: pointer;
                      border-bottom: 3px solid transparent; }
.nav a:hover, .nav button:hover { background: var(--nav-hover); text-decoration: none; color: #fff; }
.nav a.on { color: #fff; border-bottom-color: #6fb1ff; font-weight: 600; }
.nav .brand { font-weight: 700; color: #fff; margin-right: 10px; letter-spacing: .02em; }
.nav .spacer { flex: 1; }
.nav form { margin: 0; }

main { max-width: 1320px; margin: 0 auto; padding: 20px 16px 80px; }
main.wide { max-width: 1800px; }
h1 { font-size: 21px; margin: 2px 0 14px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.sub { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px;
        margin-bottom: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
@media (max-width: 600px) { .grid.two { grid-template-columns: 1fr; } }

/* フォーム */
input[type=text], input[type=password], input[type=email], input[type=date], input[type=number], select, textarea {
  padding: 7px 9px; border: 1px solid var(--border-strong); border-radius: 6px; font: inherit;
  background: var(--surface); color: var(--text); min-width: 0; }
textarea { width: 100%; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label.f { display: block; font-weight: 600; font-size: 13px; margin: 0 0 4px; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.fields .wide { grid-column: 1 / -1; }
.fields input, .fields select { width: 100%; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px;
       border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit;
       cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); border-color: var(--bad-mark); }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { display: inline-flex; gap: 5px; align-items: center; cursor: pointer; }

/* 期限ボタン(セグメント) */
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border-strong); border-radius: 7px; overflow: hidden; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { padding: 6px 12px; cursor: pointer; border-right: 1px solid var(--border); background: var(--surface); }
.seg label:last-of-type { border-right: 0; }
.seg input:checked + label { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: -2px; }

/* お知らせ */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.flash.ok { background: var(--good-bg); border-color: var(--good-mark); color: var(--text); }
.flash.error { background: var(--bad-bg); border-color: var(--bad-mark); color: var(--text); }

/* バッジ */
.b { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px;
     font-weight: 600; white-space: nowrap; line-height: 1.6; border: 1px solid transparent; }
.b::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.b.plain::before { display: none; }
.st-active    { color: var(--good); background: var(--good-bg); }
.st-expiring  { color: var(--warn); background: var(--warn-bg); }
.st-expired   { color: var(--bad); background: var(--bad-bg); }
.st-suspended { color: #fff; background: var(--bad-mark); }
.st-idle      { color: var(--off); background: var(--off-bg); }
.st-never     { color: var(--none); background: var(--none-bg); border-color: var(--none-mark); border-style: dashed; }
.ds-undistributed { color: #fff; background: #d92d20; }
.ds-distributed   { color: #fff; background: #12854a; }
.ds-manual        { color: #3a2a00; background: #f5b400; }
.ds-returned      { color: #fff; background: var(--black); }
.ds-undistributed::before, .ds-distributed::before, .ds-manual::before, .ds-returned::before { display: none; }
.md-real    { color: #fff; background: var(--accent); }
.md-demo    { color: var(--text-2); background: var(--off-bg); }
.md-contest { color: var(--text-2); background: var(--off-bg); }
.md-real::before, .md-demo::before, .md-contest::before { display: none; }
.tag { display: inline-block; padding: 0 7px; border-radius: 4px; font-size: 11px; font-weight: 600; color: #fff;
       margin: 1px 2px 1px 0; white-space: nowrap; line-height: 1.7; }
.r-OK { color: var(--good); background: var(--good-bg); }
.r-NG { color: var(--bad); background: var(--bad-bg); }
.r-WARN { color: var(--warn); background: var(--warn-bg); }

/* 集計カード */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px 12px 16px;
        position: relative; color: var(--text); box-shadow: var(--shadow); overflow: hidden; display: block; }
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--mark, var(--accent)); }
a.tile:hover { text-decoration: none; border-color: var(--border-strong); }
.tile .label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.tile .value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; }
.tile .hint { font-size: 11px; color: var(--muted); }
.tile.hero .value { font-size: 40px; }
.mk-active { --mark: var(--good-mark); } .mk-expiring { --mark: var(--warn-mark); } .mk-expired { --mark: var(--bad-mark); }
.mk-suspended { --mark: var(--bad-mark); } .mk-idle { --mark: var(--off-mark); } .mk-never { --mark: var(--none-mark); }

/* 横棒グラフ */
.bars { display: grid; grid-template-columns: minmax(90px, max-content) 1fr; gap: 6px 10px; align-items: center; }
.bars .bl { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.bars .bl a { color: var(--text); }
.bars .track { display: flex; align-items: center; gap: 6px; min-height: 22px; }
.bars .fill { display: flex; height: 16px; min-width: 2px; }
.bars .seg1 { background: var(--bar); height: 100%; border-radius: 0; }
.bars .seg2 { background: var(--bar-2); height: 100%; margin-left: 2px; border-radius: 0 4px 4px 0; }
.bars .seg1:last-child { border-radius: 0 4px 4px 0; }
.bars .v { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin: -4px 0 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* 縦棒(月別) */
.cols { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 18px; border-bottom: 1px solid var(--border); }
.cols .c { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.cols .c .bar { width: 100%; max-width: 24px; background: var(--bar); border-radius: 4px 4px 0 0; min-height: 1px; }
.cols .c .v { font-size: 11px; color: var(--text-2); margin-bottom: 2px; }
.cols-x { display: flex; gap: 6px; }
.cols-x span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); min-width: 0; overflow: hidden; }

.split { display: flex; height: 14px; border-radius: 4px; overflow: hidden; gap: 2px; margin: 8px 0 6px; }
.split span { display: block; height: 100%; }

/* 一覧表 */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar input[type=text] { width: 280px; max-width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px;
        border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip .n { font-variant-numeric: tabular-nums; opacity: .8; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--mark, var(--accent)); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: var(--surface-2); font-size: 12px; color: var(--text-2); font-weight: 600; white-space: nowrap;
     position: sticky; top: 0; z-index: 1; }
th a { color: var(--text-2); }
th a.on { color: var(--accent); }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.strip { padding: 0; width: 4px; background: var(--mark); }
tr.sel td { background: var(--accent-soft) !important; }
td[data-field] { cursor: text; }
td[data-field]:hover { outline: 1px dashed var(--border-strong); outline-offset: -3px; }
td .editor { width: 100%; min-width: 120px; }
td.saved { animation: saved 1.2s ease-out; }
@keyframes saved { from { background: var(--good-bg); } to { background: transparent; } }
.acct { font-weight: 700; font-variant-numeric: tabular-nums; }
.cell-sub { display: block; font-size: 11px; color: var(--muted); }
.expiry-warn { color: var(--warn); font-weight: 600; }
.expiry-bad { color: var(--bad); font-weight: 600; }

.bulkbar { display: none; position: sticky; bottom: 0; z-index: 15; margin-top: 12px; padding: 10px 14px;
           background: var(--nav); color: #fff; border-radius: 10px; gap: 8px; flex-wrap: wrap; align-items: center; }
.bulkbar.show { display: flex; }
.bulkbar select, .bulkbar input { background: #fff; color: #1c1f24; }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }

/* 詳細パネル */
.drawer-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 40; display: none; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); z-index: 41;
          box-shadow: -4px 0 18px rgba(0, 0, 0, .18); transform: translateX(100%); transition: transform .18s ease-out;
          overflow-y: auto; padding: 18px 20px 40px; }
.drawer.open { transform: none; }
.drawer-bg.open { display: block; }
.drawer .close { position: absolute; top: 10px; right: 12px; }
dl.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0 0 16px; }
dl.kv dt { color: var(--muted); font-size: 12px; padding-top: 2px; }
dl.kv dd { margin: 0; word-break: break-all; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-2); margin: 18px 0 8px; padding-bottom: 4px;
                 border-bottom: 1px solid var(--border); }

details.add > summary { cursor: pointer; font-weight: 700; font-size: 15px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.add > summary::-webkit-details-marker { display: none; }
details.add > summary::before { content: "＋"; display: inline-grid; place-items: center; width: 22px; height: 22px;
  border-radius: 6px; background: var(--accent); color: #fff; font-size: 14px; }
details.add[open] > summary::before { content: "－"; }
details.add[open] > summary { margin-bottom: 14px; }

pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto;
           font-size: 13px; }
.theme-btn { font-size: 15px; }
@media (max-width: 700px) {
  main { padding: 14px 12px 80px; }
  .tile .value { font-size: 24px; }
  dl.kv { grid-template-columns: 100px 1fr; }
}
