/* ================================================================
   Ad Order Desk — Design System
   ================================================================ */
:root {
  --bg: #F6F7FB;
  --surface: #FFFFFF;
  --surface-2: #F9FAFC;
  --line: #E6E8F0;
  --line-2: #EEF0F5;
  --text: #121826;
  --text-2: #4A5368;
  --text-3: #8790A6;
  --brand: #4F46E5;
  --brand-2: #6366F1;
  --brand-weak: #EEF0FF;
  --brand-ink: #3730A3;
  --red: #E5484D;  --red-weak: #FDECEC;
  --amber: #D97706; --amber-weak: #FEF3E2;
  --green: #12A150; --green-weak: #E6F6EC;
  --blue: #2563EB; --blue-weak: #E8F0FE;
  --violet: #7C3AED; --violet-weak: #F1EBFE;
  --gray: #64748B; --gray-weak: #F1F3F7;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg: 0 12px 32px -8px rgba(16,24,40,.18), 0 4px 8px -4px rgba(16,24,40,.06);
  --sidebar: 240px;
  --font: 'Inter', 'Noto Sans JP', system-ui, -apple-system, 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
}
[data-theme="dark"] {
  --bg: #0E1117; --surface: #161A22; --surface-2: #1B2029; --line: #2A303C; --line-2: #222833;
  --text: #E9ECF2; --text-2: #B3BACB; --text-3: #7C8599;
  --brand: #818CF8; --brand-2: #818CF8; --brand-weak: #23264A; --brand-ink: #C7CBFF;
  --red-weak: #3A1C1F; --amber-weak: #3A2A12; --green-weak: #12301F; --blue-weak: #172645; --violet-weak: #2A1D47; --gray-weak: #232934;
  --shadow: 0 1px 3px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.6; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-feature-settings: "palt" 1;
}
a { color: var(--brand); text-decoration: none; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; letter-spacing: .01em; }
.ic { flex: none; vertical-align: middle; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, #6366F1, #8B5CF6 60%, #EC4899); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px; box-shadow: 0 4px 12px -2px rgba(99,102,241,.5); }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--text-3); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; color: var(--text-3); font-weight: 600; padding: 14px 12px 6px; letter-spacing: .06em; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; color: var(--text-2); font-weight: 500;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--brand-weak); color: var(--brand-ink); }
.nav a .count { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 0 7px; min-width: 20px; text-align: center; line-height: 18px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none; }
.me-name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.me-role { font-size: 11px; color: var(--text-3); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px);
  display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid transparent;
}
.topbar h1 { font-size: 20px; font-weight: 700; }
.topbar .crumb { color: var(--text-3); font-size: 13px; }
.topbar .spacer { flex: 1; }
.content { padding: 8px 28px 48px; max-width: 1480px; width: 100%; }
.content.narrow { max-width: 1080px; }
.demo-banner { background: linear-gradient(90deg, #FEF3C7, #FDE68A); color: #78350F; font-size: 12px; padding: 6px 16px; text-align: center; }
.demo-banner button { background: rgba(255,255,255,.6); border: 0; border-radius: 6px; padding: 1px 8px; margin-left: 8px; cursor: pointer; font-size: 12px; }

/* bottom tab (mobile) */
.tabbar { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, transform .05s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: #D5D9E4; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(79,70,229,.3), inset 0 1px 0 rgba(255,255,255,.15); }
.btn-primary:hover { background: #4338CA; border-color: #4338CA; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #0E8A44; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--gray-weak); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14px; border-radius: 11px; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 0; background: transparent; border-radius: 8px; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--gray-weak); color: var(--text); }
.btn-group { display: inline-flex; background: var(--gray-weak); padding: 3px; border-radius: 10px; gap: 2px; }
.btn-group button { border: 0; background: transparent; height: 30px; padding: 0 12px; border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; color: var(--text-2); }
.btn-group button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head .spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { justify-content: space-between; }

/* KPI */
.kpi { padding: 18px 20px; position: relative; overflow: hidden; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-label { font-size: 12px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--text-3); }
.kpi-ic { position: absolute; right: 16px; top: 16px; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.kpi.alert { border-color: #F8C9CB; background: linear-gradient(180deg, #FFF7F7, var(--surface)); }
[data-theme="dark"] .kpi.alert { background: var(--surface); border-color: #5b2a2d; }

/* ---------- Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-red { background: var(--red-weak); color: var(--red); }
.badge-amber { background: var(--amber-weak); color: var(--amber); }
.badge-green { background: var(--green-weak); color: var(--green); }
.badge-blue { background: var(--blue-weak); color: var(--blue); }
.badge-violet { background: var(--violet-weak); color: var(--violet); }
.badge-gray { background: var(--gray-weak); color: var(--gray); }
.badge-muted { background: var(--gray-weak); color: var(--text-3); }
.mchip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px 0 7px; border-radius: 7px; font-size: 12px; font-weight: 600; background: color-mix(in srgb, var(--mc) 10%, var(--surface)); color: var(--text); border: 1px solid color-mix(in srgb, var(--mc) 25%, transparent); white-space: nowrap; }
.mchip i { width: 8px; height: 8px; border-radius: 3px; background: var(--mc); }
.mchip-sm { height: 20px; font-size: 11px; padding: 0 7px 0 5px; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--gray-weak); color: var(--text-2); font-size: 12px; }
.cstat { font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.cstat-none { color: var(--text-3); } .cstat-partial { color: var(--amber); } .cstat-complete { color: var(--green); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 700; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.req { color: var(--red); font-size: 11px; font-weight: 700; }
.opt { color: var(--text-3); font-size: 11px; font-weight: 500; }
.hint { font-size: 12px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface);
  transition: border-color .12s, box-shadow .12s; outline: none;
}
.textarea { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 18%, transparent); }
.input.err, .textarea.err { border-color: var(--red); background: color-mix(in srgb, var(--red) 3%, var(--surface)); }
.input.warn, .textarea.warn { border-color: #F2C27B; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238790A6' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.input-yen { position: relative; }
.input-yen::before { content: '¥'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-weight: 600; }
.input-yen .input { padding-left: 26px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.input-yen small { position: absolute; right: -2px; bottom: -18px; font-size: 11px; color: var(--text-3); }

/* toggle chips (multi select) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 500; user-select: none; transition: all .12s;
}
.chip:hover { border-color: #C9CEDB; }
.chip input { display: none; }
.chip.on, .chip:has(input:checked) { background: var(--brand-weak); border-color: color-mix(in srgb, var(--brand) 45%, transparent); color: var(--brand-ink); font-weight: 700; }
.chip.on::before, .chip:has(input:checked)::before { content: '✓'; font-size: 11px; }
.chip-all { border-style: dashed; color: var(--text-2); }

/* media picker tiles */
.media-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.mtile {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface);
  cursor: pointer; transition: all .14s; user-select: none;
}
.mtile:hover { border-color: color-mix(in srgb, var(--mc) 50%, var(--line)); transform: translateY(-1px); }
.mtile .mdot { width: 34px; height: 34px; border-radius: 10px; background: color-mix(in srgb, var(--mc) 14%, var(--surface)); color: var(--mc); display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.mtile .mname { font-weight: 700; font-size: 13.5px; line-height: 1.3; }
.mtile .mcheck { position: absolute; right: 10px; top: 10px; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; color: #fff; }
.mtile.on { border-color: var(--mc); background: color-mix(in srgb, var(--mc) 6%, var(--surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mc) 14%, transparent); }
.mtile.on .mcheck { background: var(--mc); border-color: var(--mc); }

/* ---------- Wizard ---------- */
.wizard { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.steps { display: flex; gap: 4px; margin-bottom: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 6px; box-shadow: var(--shadow); }
.step { flex: 1; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; cursor: pointer; color: var(--text-3); font-weight: 600; font-size: 13px; border: 0; background: transparent; text-align: left; }
.step .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--gray-weak); font-size: 12px; font-weight: 800; flex: none; }
.step.done { color: var(--text-2); } .step.done .n { background: var(--green-weak); color: var(--green); }
.step.on { background: var(--brand-weak); color: var(--brand-ink); } .step.on .n { background: var(--brand); color: #fff; }
.step small { display: block; font-size: 11px; font-weight: 500; opacity: .8; }
.summary { position: sticky; top: 80px; }
.summary .tot { font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.summary-line { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; padding: 6px 0; border-bottom: 1px dashed var(--line-2); }
.wizard-foot { position: sticky; bottom: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 14px 0; margin-top: 20px; background: linear-gradient(0deg, var(--bg) 70%, transparent); }
.wizard-foot .spacer { flex: 1; }
.autosave { font-size: 12px; color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; }

/* placement block */
.pl { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.pl + .pl { margin-top: 14px; }
.pl-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line-2); cursor: pointer; }
.pl-head .t { font-weight: 700; }
.pl-head .meta { color: var(--text-3); font-size: 12px; }
.pl-head .spacer { flex: 1; }
.pl-body { padding: 18px; display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px 18px; }
.pl.collapsed .pl-body { display: none; }
.c12 { grid-column: span 12; } .c8 { grid-column: span 8; } .c6 { grid-column: span 6; } .c4 { grid-column: span 4; } .c3 { grid-column: span 3; }
.media-group { margin-bottom: 26px; }
.media-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.media-group-head h3 { font-size: 16px; }
.addtype { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.addtype button { border: 1px dashed var(--line); background: transparent; border-radius: 8px; height: 30px; padding: 0 10px; font-size: 12px; font-weight: 600; color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.addtype button:hover { border-color: var(--brand-2); color: var(--brand); background: var(--brand-weak); }
.addtype button.spec::after { content: '仕様あり'; font-size: 10px; background: var(--green-weak); color: var(--green); border-radius: 4px; padding: 0 4px; margin-left: 2px; }

/* ---------- Creative form ---------- */
.cr { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 20px; }
.cr-main { display: flex; flex-direction: column; gap: 18px; }
.cr-side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 80px; align-self: start; max-height: calc(100vh - 100px); overflow: auto; }
.tl-item { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: start; }
.tl-item + .tl-item { margin-top: 6px; }
.tl-n { height: 38px; display: grid; place-items: center; font-size: 11px; color: var(--text-3); font-weight: 700; }
.counter { font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--text-3); height: 38px; display: flex; align-items: center; min-width: 56px; justify-content: flex-end; }
.counter.over { color: var(--red); font-weight: 700; }
.counter.near { color: var(--amber); }
.issues { grid-column: 2 / 4; display: flex; flex-direction: column; gap: 3px; margin-top: 2px; }
.issue { font-size: 12px; display: flex; gap: 6px; align-items: flex-start; line-height: 1.45; }
.issue.error { color: var(--red); } .issue.warn { color: var(--amber); }
.issue .ic { margin-top: 2px; }
.add-line { margin-top: 8px; }
.notes { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.notes summary { padding: 11px 14px; cursor: pointer; font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 8px; list-style: none; }
.notes summary::-webkit-details-marker { display: none; }
.notes summary::after { content: ''; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg); transition: transform .15s; }
.notes[open] summary::after { transform: rotate(-135deg); }
.notes .nb { padding: 0 14px 14px; font-size: 12.5px; color: var(--text-2); white-space: pre-wrap; line-height: 1.75; }
.check-card { padding: 14px; }
.check-row { display: flex; gap: 8px; font-size: 12.5px; padding: 4px 0; }

/* dropzone & image grid */
.drop {
  border: 1.5px dashed #CBD1DE; border-radius: 12px; padding: 18px; text-align: center; color: var(--text-2); cursor: pointer; background: var(--surface-2); transition: all .15s;
}
.drop:hover, .drop.over { border-color: var(--brand-2); background: var(--brand-weak); color: var(--brand-ink); }
.drop b { color: var(--brand); }
.ratio-guide { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.rg { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 12px; background: var(--surface); }
.rg .shape { background: color-mix(in srgb, var(--brand-2) 18%, transparent); border: 1.5px solid var(--brand-2); border-radius: 3px; }
.rg.ok { border-color: color-mix(in srgb, var(--green) 50%, transparent); background: var(--green-weak); }
.rg.ok .shape { background: var(--green); border-color: var(--green); }
.rg .need { font-size: 10px; font-weight: 700; color: var(--red); }
.imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; margin-top: 10px; }
.img { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.img .th { aspect-ratio: 1; background: repeating-conic-gradient(#F1F3F7 0% 25%, #fff 0% 50%) 50% / 16px 16px; display: grid; place-items: center; overflow: hidden; }
.img .th img { max-width: 100%; max-height: 100%; object-fit: contain; }
.img .meta { padding: 6px 8px; font-size: 11px; line-height: 1.4; }
.img .meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--text); }
.img.err { border-color: var(--red); box-shadow: 0 0 0 2px var(--red-weak); }
.img .x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: rgba(17,24,39,.65); color: #fff; border: 0; cursor: pointer; display: grid; place-items: center; }
.img .rlabel { position: absolute; top: 6px; left: 6px; font-size: 10px; font-weight: 700; background: rgba(17,24,39,.7); color: #fff; padding: 1px 6px; border-radius: 4px; }
.img .issue { padding: 0 8px 6px; font-size: 11px; }

/* carousel cards */
.ccards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.ccard { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.ccard-h { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 12px; }
.ccard .th { aspect-ratio: 1; border-radius: 8px; border: 1.5px dashed #CBD1DE; display: grid; place-items: center; overflow: hidden; cursor: pointer; background: var(--surface); color: var(--text-3); font-size: 12px; text-align: center; }
.ccard .th img { width: 100%; height: 100%; object-fit: contain; }
.ccard .input { height: 34px; font-size: 13px; }

/* ---------- Table ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.search { position: relative; }
.search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search .input { padding-left: 34px; width: 260px; }
.select.fsel, .fsel { width: auto; max-width: 220px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background-color: var(--surface); padding: 0 30px 0 10px; font-size: 13px; }
.table-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); max-height: calc(100vh - 230px); }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.t th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left; font-size: 11.5px; font-weight: 700; color: var(--text-2); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
.t th.sorted { color: var(--brand); }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.t tbody tr { transition: background .08s; cursor: pointer; }
.t tbody tr:hover { background: var(--surface-2); }
.t tbody tr.sel { background: var(--brand-weak); }
.t td.num, .t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.t .group-row td { background: var(--bg); font-weight: 700; font-size: 12.5px; padding: 8px 12px; position: sticky; top: 37px; z-index: 1; cursor: default; }
.t .cb { width: 36px; }
.t input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 11.5px; color: var(--text-3); }
.period { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bulkbar { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: #111827; color: #fff; border-radius: 14px; padding: 8px 8px 8px 16px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-lg); }
.bulkbar select { background: #1F2937; color: #fff; border: 1px solid #374151; border-radius: 8px; height: 32px; padding: 0 8px; }

/* Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: var(--gray-weak); border-radius: 14px; padding: 10px; min-height: 300px; display: flex; flex-direction: column; gap: 8px; }
.kcol.over { outline: 2px dashed var(--brand-2); outline-offset: -4px; }
.kcol-h { display: flex; align-items: center; gap: 8px; padding: 4px 4px 6px; font-weight: 700; font-size: 13px; }
.kcol-h .n { margin-left: auto; color: var(--text-3); font-size: 12px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow-sm); cursor: grab; display: flex; flex-direction: column; gap: 6px; }
.kcard:hover { box-shadow: var(--shadow-lg); }
.kcard.dragging { opacity: .5; }
.kcard .kc-t { font-weight: 700; font-size: 13px; line-height: 1.35; }

/* Gantt */
.gantt { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); max-height: calc(100vh - 230px); }
.gantt-grid { display: grid; position: relative; min-width: max-content; }
.g-head { position: sticky; top: 0; z-index: 3; background: var(--surface-2); border-bottom: 1px solid var(--line); display: contents; }
.g-label { position: sticky; left: 0; z-index: 2; background: var(--surface); border-right: 1px solid var(--line); padding: 6px 12px; font-size: 12px; min-height: 40px; display: flex; flex-direction: column; justify-content: center; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.g-label:hover { background: var(--surface-2); }
.g-days { display: grid; position: relative; border-bottom: 1px solid var(--line-2); }
.g-day { border-right: 1px solid var(--line-2); font-size: 10px; text-align: center; color: var(--text-3); }
.g-day.we { background: color-mix(in srgb, var(--gray-weak) 60%, transparent); }
.g-day.today { background: color-mix(in srgb, var(--red) 8%, transparent); }
.g-bar { position: absolute; top: 9px; height: 22px; border-radius: 6px; font-size: 11px; color: #fff; font-weight: 700; padding: 0 8px; display: flex; align-items: center; overflow: hidden; white-space: nowrap; box-shadow: 0 1px 2px rgba(0,0,0,.15); cursor: pointer; }
.g-month { font-size: 11px; font-weight: 700; padding: 4px 6px; border-right: 1px solid var(--line); color: var(--text-2); white-space: nowrap; }
.g-todayline { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); z-index: 1; pointer-events: none; }

/* bar chart */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 110px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-track { height: 10px; background: var(--gray-weak); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; }
.month-chart { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.mc-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.mc-bar { width: 100%; max-width: 44px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, var(--brand-2), color-mix(in srgb, var(--brand-2) 55%, transparent)); min-height: 3px; }
.mc-bar.cur { background: linear-gradient(180deg, #EC4899, #8B5CF6); }
.mc-l { font-size: 11px; color: var(--text-3); }
.mc-v { font-size: 10.5px; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* list items */
.li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.li:last-child { border-bottom: 0; }
.li:hover { background: var(--surface-2); }
.li .grow { flex: 1; min-width: 0; }
.li .ttl { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* request cards (requester list / mobile) */
.rcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.rcard { padding: 16px 18px; cursor: pointer; transition: transform .12s, box-shadow .12s; display: flex; flex-direction: column; gap: 10px; }
.rcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.rcard .rc-t { font-size: 15px; font-weight: 700; }
.rcard .rc-c { font-size: 12px; color: var(--text-3); }
.receipt { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--green); background: var(--green-weak); padding: 3px 10px; border-radius: 99px; }

/* detail */
.detail { display: grid; grid-template-columns: minmax(0,1fr) 360px; gap: 20px; align-items: start; }
.hero { padding: 22px 24px; display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.hero h2 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: 13px; }
.dl dt { color: var(--text-3); font-weight: 600; }
.dl dd { margin: 0; min-width: 0; word-break: break-word; }
.receive-box { border-radius: 14px; padding: 18px; background: linear-gradient(135deg, #EEF2FF, #FDF2F8); border: 1px solid #E0E7FF; }
[data-theme="dark"] .receive-box { background: var(--surface-2); border-color: var(--line); }
.receive-box.done { background: var(--green-weak); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.thread { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px; max-height: 420px; overflow: auto; }
.msg { display: flex; gap: 10px; }
.msg .bubble { background: var(--surface-2); border: 1px solid var(--line-2); padding: 8px 12px; border-radius: 4px 12px 12px 12px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.msg.mine { flex-direction: row-reverse; }
.msg.mine .bubble { background: var(--brand-weak); border-color: transparent; border-radius: 12px 4px 12px 12px; }
.msg .who { font-size: 11px; color: var(--text-3); margin-bottom: 2px; }
.msg.mine .who { text-align: right; }
.timeline { padding: 12px 20px; display: flex; flex-direction: column; gap: 10px; font-size: 12.5px; }
.tl-ev { display: flex; gap: 10px; }
.tl-ev .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-2); margin-top: 7px; flex: none; }
.cr-view { display: flex; flex-direction: column; gap: 12px; }
.cr-row { display: grid; grid-template-columns: 170px 1fr; gap: 12px; font-size: 13px; padding: 8px 0; border-bottom: 1px dashed var(--line-2); }
.cr-row .k { color: var(--text-3); font-weight: 600; }
.cr-row ol { margin: 0; padding-left: 20px; }
.cr-row li { padding: 1px 0; }
.cr-row li .cnt { color: var(--text-3); font-size: 11px; margin-left: 6px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs a { display: block; width: 92px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface-2); font-size: 10px; color: var(--text-3); text-align: center; }
.thumbs img { width: 100%; height: 72px; object-fit: contain; display: block; background: repeating-conic-gradient(#F1F3F7 0% 25%, #fff 0% 50%) 50% / 12px 12px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 12px 12px; font-weight: 600; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.tabs button.on { color: var(--text); border-color: var(--brand); }

/* empty / misc */
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty h4 { margin-top: 10px; color: var(--text-2); font-size: 15px; }
.empty p { margin: 6px 0 14px; font-size: 13px; }
.divider { height: 1px; background: var(--line-2); margin: 4px 0; }
.alert-box { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; font-size: 13px; }
.alert-box.info { background: var(--blue-weak); color: #1E40AF; }
.alert-box.warn { background: var(--amber-weak); color: #92400E; }
.alert-box.err { background: var(--red-weak); color: #991B1B; }
.alert-box.ok { background: var(--green-weak); color: #166534; }
[data-theme="dark"] .alert-box { color: var(--text); }

/* modal & toast */
.modal-wrap { position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,.42); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; animation: fade .15s; }
.modal-wrap.out { opacity: 0; transition: opacity .15s; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); animation: pop .18s cubic-bezier(.2,.9,.3,1.2); }
.modal-wide { width: min(880px, 100%); }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.modal-head h3 { font-size: 16px; flex: 1; }
.modal-body { padding: 20px; overflow: auto; }
.modal-body p { margin: 0 0 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-2); }
@keyframes pop { from { transform: scale(.96) translateY(6px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
#toasts { position: fixed; right: 20px; top: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; background: #111827; color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 13px; animation: pop .2s; max-width: 420px; }
.toast-ok .ic { color: #4ADE80; } .toast-error .ic { color: #F87171; }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .3s; }

/* login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: radial-gradient(1200px 600px at 10% 10%, #6366F1 0%, transparent 60%), radial-gradient(900px 500px at 90% 90%, #EC4899 0%, transparent 55%), #1E1B4B; color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h2 { font-size: 34px; line-height: 1.3; font-weight: 800; letter-spacing: -.01em; }
.login-art p { opacity: .8; max-width: 440px; }
.login-feats { display: grid; gap: 12px; max-width: 440px; }
.login-feats div { display: flex; gap: 12px; align-items: center; background: rgba(255,255,255,.08); padding: 12px 14px; border-radius: 12px; backdrop-filter: blur(8px); font-size: 13px; }
.login-form { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.login-box { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; }
.login-box h1 { font-size: 24px; font-weight: 800; }
.demo-users { display: grid; gap: 8px; }
.demo-users button { display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--line); background: var(--surface); padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.demo-users button:hover { border-color: var(--brand-2); background: var(--brand-weak); }

/* json editor */
.code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; min-height: 420px; white-space: pre; tab-size: 2; }

/* ================================================================
   Responsive
   ================================================================ */
@media (max-width: 1200px) {
  .wizard, .detail, .cr { grid-template-columns: 1fr; }
  .summary, .cr-side { position: static; max-height: none; }
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 860px) {
  body { font-size: 15px; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 12px 16px; }
  .topbar h1 { font-size: 18px; }
  .content { padding: 4px 14px 96px; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 600; color: var(--text-3); padding: 4px 0; position: relative; }
  .tabbar a.active { color: var(--brand); }
  .tabbar a.fab .ic { background: var(--brand); color: #fff; border-radius: 14px; width: 44px; height: 32px; padding: 6px; box-shadow: 0 4px 12px -2px rgba(79,70,229,.5); }
  .tabbar a .count { position: absolute; top: 0; right: calc(50% - 20px); background: var(--red); color: #fff; font-size: 10px; border-radius: 99px; padding: 0 5px; line-height: 16px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .g4.kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 22px; }
  .steps { overflow-x: auto; }
  .step small { display: none; }
  .step { flex: none; padding: 8px 10px; }
  .step:not(.on) .lbl { display: none; }
  .pl-body { grid-template-columns: 1fr; padding: 14px; }
  .pl-body > * { grid-column: span 1 !important; }
  .input, .select { height: 44px; font-size: 16px; }
  .textarea { font-size: 16px; }
  .chip { height: 38px; padding: 0 14px; }
  .btn { height: 42px; }
  .btn-sm { height: 34px; }
  .media-tiles { grid-template-columns: 1fr 1fr; }
  .mtile { padding: 12px; }
  .mtile .mdot { width: 28px; height: 28px; }
  .wizard-foot { bottom: 62px; }
  .wizard-foot .btn { flex: 1; }
  .wizard-foot .autosave { display: none; }
  .search .input { width: 100%; }
  .search { flex: 1 1 100%; }
  .toolbar .fsel { flex: 1 1 45%; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dt { margin-top: 8px; }
  .cr-row { grid-template-columns: 1fr; gap: 4px; }
  .bar-row { grid-template-columns: 100px 1fr 80px; }
  .rcards { grid-template-columns: 1fr; }
  .bulkbar { bottom: 74px; left: 12px; right: 12px; transform: none; flex-wrap: wrap; }
  #toasts { left: 12px; right: 12px; top: 12px; }
  .toolbar .filters { display: none; width: 100%; flex-wrap: wrap; gap: 8px; }
  .toolbar.open .filters { display: flex; }
  .toolbar .filters .fsel { flex: 1 1 100%; height: 42px; }
  .filter-toggle { display: inline-flex !important; }
  .hide-sm { display: none !important; }
  .imgs { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 861px) { .show-sm { display: none !important; } .toolbar .filters { display: contents; } .filter-toggle { display: none !important; } }
@media print { .sidebar, .topbar, .tabbar, .wizard-foot { display: none !important; } .shell { display: block; } }

/* ---------- アプリ内お知らせ ---------- */
.notif-btn{position:relative}
.notif-dot{position:absolute;top:-2px;right:-4px;min-width:16px;height:16px;padding:0 4px;border-radius:8px;background:#EF4444;color:#fff;font-size:10px;font-weight:700;line-height:16px;text-align:center}
.notif-dot.hide{display:none}
.notif-fab{display:none}
.notif-panel-wrap{position:fixed;inset:0;z-index:200;background:rgba(15,23,42,.45);backdrop-filter:blur(2px)}
.notif-panel{position:absolute;color:var(--text);left:250px;bottom:16px;width:360px;max-height:70vh;display:flex;flex-direction:column;background:var(--surface);border:1px solid var(--line);border-radius:14px;box-shadow:0 20px 50px rgba(15,23,42,.18);overflow:hidden}
.notif-head{display:flex;align-items:center;justify-content:space-between;padding:12px 14px;border-bottom:1px solid var(--line)}
.notif-list{overflow:auto}
.notif-item{display:block;padding:12px 16px;border-bottom:1px solid var(--line);color:inherit;text-decoration:none}
.notif-item:hover{background:var(--hover,rgba(99,102,241,.06))}
.notif-item.unread{background:var(--brand-weak);box-shadow:inset 3px 0 0 #6366F1}
.notif-title{font-weight:700;font-size:14px}
.notif-body{font-size:13px;opacity:.8;margin-top:2px;word-break:break-all}
.notif-time{font-size:11px;opacity:.55;margin-top:4px}
.notif-empty{padding:32px;text-align:center;opacity:.6;font-size:14px}
@media (max-width:860px){
  .notif-fab{display:flex;align-items:center;justify-content:center;position:fixed;top:10px;right:12px;z-index:90;width:40px;height:40px;border-radius:50%;border:1px solid var(--line);background:var(--surface);box-shadow:0 4px 14px rgba(15,23,42,.12);color:inherit}
  .notif-fab .notif-dot{top:-3px;right:-3px}
  .notif-panel{left:8px;right:8px;top:58px;bottom:auto;width:auto}
}
