:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f0f1f4;
  --line: #e2e4ea;
  --text: #1c1e24;
  --muted: #6b7280;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --danger: #d9534f;
  --ok: #2aa876;
  --warn: #e8a317;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181d;
    --panel: #1f2229;
    --panel-2: #262a33;
    --line: #333845;
    --text: #e6e8ee;
    --muted: #9aa1b1;
    --accent: #5b8def;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
    --bg: #16181d;
    --panel: #1f2229;
    --panel-2: #262a33;
    --line: #333845;
    --text: #e6e8ee;
    --muted: #9aa1b1;
    --accent: #5b8def;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 13px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- topbar ---------- */
body.web .topbar { padding-left: 16px; -webkit-app-region: no-drag; }
body.web .guide-link { display: inline-flex; }
.guide-link { display: none; color: var(--muted); text-decoration: none; font-size: 12px; align-items: center; }
.guide-link:hover { color: var(--text); }
body.web main { height: calc(100% - 52px); }
@media (max-width: 760px) { body.web .topbar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; } body.web main { height: auto; } body.web .view { padding: 12px; } body.web .companies, body.web .settings { grid-template-columns: 1fr; } body.web .modal-card { width: 96vw; } }
.topbar { -webkit-app-region: drag; height: 52px; display: flex; align-items: center; gap: 16px; padding: 0 16px 0 84px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar button, .topbar input, .topbar label { -webkit-app-region: no-drag; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.logo { width: 16px; height: 16px; border-radius: 5px; background: linear-gradient(135deg, #2f6fed, #8a5cf6); display: inline-block; }
.tabs { display: flex; gap: 2px; background: var(--panel-2); padding: 3px; border-radius: 8px; }
.tabs button { border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.tabs button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.top-running { font-variant-numeric: tabular-nums; color: var(--muted); }
.meeting { display: flex; align-items: center; gap: 4px; color: var(--muted); cursor: pointer; }

main { height: calc(100% - 52px); overflow: auto; }
.view { display: none; padding: 18px 22px 40px; }
.view.active { display: block; }

/* ---------- buttons/forms ---------- */
.btn { border: 1px solid var(--line); background: var(--panel); padding: 6px 12px; border-radius: 7px; cursor: pointer; line-height: 1.3; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.stop { background: var(--danger); color: #fff; border-color: transparent; }
.btn:disabled { opacity: 0.5; cursor: default; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=url], select, textarea { border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: 6px 8px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.section-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 18px 0 8px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.chip.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11px; color: var(--muted); }
.stats { display: flex; gap: 24px; }
.warn { color: var(--warn); }
.err { color: var(--danger); font-size: 12px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 500; color: var(--muted); font-size: 12px; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.off td { color: var(--muted); }
tr.weekend td { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; }

/* ---------- today ---------- */
.day-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.day-head .date { font-size: 18px; font-weight: 600; }
.running-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; margin-bottom: 14px; }
.run-card { border-left: 4px solid var(--accent); display: flex; flex-direction: column; gap: 6px; }
.run-card .elapsed { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.run-card input { width: 100%; }
.quick-start { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.quick-start input { width: 100%; }
.company-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.company-buttons .btn { display: inline-flex; align-items: center; gap: 6px; }
.timeline { display: grid; grid-template-columns: 56px 1fr; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.tl-hours { position: relative; border-right: 1px solid var(--line); }
.tl-hours div { position: absolute; left: 0; right: 6px; text-align: right; font-size: 11px; color: var(--muted); transform: translateY(-50%); }
.tl-lanes { position: relative; }
.tl-grid { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.tl-now { position: absolute; left: 0; right: 0; border-top: 2px solid var(--danger); z-index: 2; }
.tl-block { position: absolute; border-radius: 6px; padding: 4px 6px; color: #fff; font-size: 11px; overflow: hidden; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.15); z-index: 1; }
.tl-block .t { opacity: 0.85; font-variant-numeric: tabular-nums; }
.tl-block.running { outline: 2px dashed rgba(255,255,255,0.7); outline-offset: -3px; }
.gaps { margin-top: 10px; }

/* ---------- list ---------- */
.list-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.list-head .month { font-size: 18px; font-weight: 600; }
.actions .btn { margin-right: 4px; }

/* ---------- export ---------- */
.export-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.export-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.help { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.preview-wrap { max-height: 520px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.preview-wrap table th { position: sticky; top: 0; background: var(--panel); }

/* ---------- companies ---------- */
.companies { display: grid; grid-template-columns: 300px 1fr; gap: 18px; }
.co-list .item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.co-list .item.active { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.co-list .item .n { flex: 1; }
.co-form .field input[type=text], .co-form .field input[type=url], .co-form .field input[type=number], .co-form select, .co-form textarea { width: 100%; }

/* ---------- settings ---------- */
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 1000px; }
.settings .card h3 { margin: 0 0 10px; font-size: 14px; }
.settings .line { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.settings .line input[type=number] { width: 72px; }
.settings .line input[type=time] { width: 110px; }
.kv { font-size: 12px; color: var(--muted); word-break: break-all; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: none; align-items: center; justify-content: center; z-index: 50; }
.modal.open { display: flex; }
.modal-card { width: 560px; max-height: 90vh; overflow: auto; background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); padding: 18px 20px; }
.modal-card h2 { margin-bottom: 14px; }
.seg { display: inline-flex; background: var(--panel-2); border-radius: 7px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 5px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; align-items: center; }
.modal-foot .spacer { flex: 1; }
.modal input[type=text], .modal input[type=date], .modal select, .modal textarea { width: 100%; }
.modal .row input[type=text] { width: auto; flex: 1; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 8px 12px; border-radius: 8px; box-shadow: var(--shadow); font-size: 12px; animation: fade 0.2s ease-out; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

/* ---------- quick window ---------- */
.quick-body { background: transparent; }
.quick { height: 100vh; display: flex; flex-direction: column; background: var(--panel); border-radius: 12px; border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.quick-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); -webkit-app-region: no-drag; }
.quick-head-right { display: flex; align-items: center; gap: 8px; }
.q-running { padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; max-height: 190px; overflow: auto; }
.q-run { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--panel-2); }
.q-run .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-run .e { font-variant-numeric: tabular-nums; font-weight: 600; }
.q-start { padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; overflow: auto; }
.q-start input { width: 100%; }
.q-companies { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.q-companies .btn { display: flex; align-items: center; gap: 6px; justify-content: flex-start; text-align: left; }
.q-foot { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-top: 1px solid var(--line); }

/* ---------- mini calendar ---------- */
.cal-anchor { position: relative; display: inline-block; }
.date-btn { background: none; border: 0; cursor: pointer; padding: 2px 6px; border-radius: 6px; font: inherit; color: inherit; }
.date-btn:hover { background: var(--panel-2); }
.minical { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: 300px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 12px 8px; font-size: 13px; }
.minical-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.minical-title { font-weight: 600; font-size: 14px; }
.minical-nav .btn { padding: 2px 8px; font-size: 14px; }
.minical-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px 0; }
.minical-dow { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.minical-dow.sun { color: #d9534f; } .minical-dow.sat { color: #2f6fed; }
.minical-day { position: relative; height: 36px; border: 0; background: transparent; border-radius: 50%; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--text); font-variant-numeric: tabular-nums; }
.minical-day:hover { background: var(--panel-2); }
.minical-day.other { color: var(--muted); opacity: 0.55; }
.minical-day.sun:not(.other) .n { color: #d9534f; } .minical-day.sat:not(.other) .n { color: #2f6fed; }
.minical-day.today { background: var(--accent); color: #fff; }
.minical-day.today .n, .minical-day.today.sat:not(.other) .n, .minical-day.today.sun:not(.other) .n { color: #fff; }
.minical-day.selected:not(.today) { box-shadow: inset 0 0 0 2px var(--accent); }
.minical-day .n { font-size: 13px; line-height: 1; }
.minical-day .dots { display: flex; gap: 2px; height: 4px; }
.minical-day .dots i { width: 4px; height: 4px; border-radius: 50%; display: inline-block; }
.minical-day.today .dots i { background: #fff !important; }
.minical-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
