/* DLP STAFF PORTAL — スマホ最優先・毎日使う業務画面のためのシンプルなスタイル */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1b2430;
  --muted: #5d6877;
  --line: #e1e6ed;
  --accent: #1f5fbf;
  --accent-weak: #e8f0fc;
  --ok: #15803d;
  --warn: #b45309;
  --warn-weak: #fff4e5;
  --danger: #b91c1c;
  --danger-weak: #fdecec;
  --radius: 14px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  line-height: 1.55; -webkit-text-size-adjust: 100%; overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ── 骨組み ── */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; min-height: 56px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}
.topbar .back { border: 0; background: none; font-size: 1.5rem; width: 44px; height: 44px; margin-left: -8px; border-radius: 10px; cursor: pointer; }
.topbar .back:active { background: var(--accent-weak); }
.topbar h1 { font-size: 1.08rem; margin: 0; flex: 1; font-weight: 700; letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .who { font-size: .8rem; color: var(--muted); text-align: right; line-height: 1.3; }
main { max-width: 960px; margin: 0 auto; padding: 14px 14px calc(var(--nav-h) + 28px + var(--safe-b)); }
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line);
  display: flex; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600;
}
.bottomnav a .i { font-size: 1.35rem; line-height: 1; }
.bottomnav a.on { color: var(--accent); }
@media (min-width: 900px) {
  .bottomnav { top: 0; bottom: 0; right: auto; width: 92px; height: auto; flex-direction: column; justify-content: flex-start; padding-top: 70px; border-top: 0; border-right: 1px solid var(--line); }
  .bottomnav a { flex: 0 0 78px; }
  .topbar, main { margin-left: 92px; }
  main { padding-bottom: 40px; }
}

/* ── 部品 ── */
.section-title { display: flex; align-items: center; gap: 8px; font-size: .95rem; font-weight: 700; color: var(--muted); margin: 22px 4px 10px; }
.section-title:first-child { margin-top: 4px; }
.section-title .ic { font-size: 1.1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 10px; }
.stack > * + * { margin-top: 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.notice { background: var(--accent-weak); border-radius: 12px; padding: 12px 14px; font-size: .92rem; }
.notice.warn { background: var(--warn-weak); color: #6b3d06; }
.notice.danger { background: var(--danger-weak); color: #7f1d1d; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; font-size: .95rem; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.tile {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  min-height: 96px; padding: 14px 12px 12px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; width: 100%; -webkit-tap-highlight-color: transparent;
}
.tile:active { transform: scale(.98); background: #f8fafc; }
.tile .ti { font-size: 1.75rem; line-height: 1; }
.tile .tn { font-weight: 700; font-size: .98rem; line-height: 1.3; padding-right: 30px; word-break: break-word; }
.tile .td { font-size: .78rem; color: var(--muted); line-height: 1.35; }
.tile.dim { opacity: .62; }
.tile .badge { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #eef1f5; color: var(--muted); }
.tile .badge.paused { background: var(--warn-weak); color: var(--warn); }
.tile .star {
  position: absolute; top: 4px; right: 4px; width: 40px; height: 40px; border: 0; background: none; border-radius: 10px;
  font-size: 1.2rem; color: #c2c9d3; cursor: pointer;
}
.tile .star.on { color: #f59e0b; }
.tile.folder { flex-direction: row; align-items: center; min-height: 72px; grid-column: 1 / -1; }
.tile.folder .tn { padding-right: 0; flex: 1; }
.tile.folder .chev { font-size: 1.3rem; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { color: var(--danger); border-color: #f3c4c4; }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: .88rem; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

.search { position: relative; }
.search input {
  width: 100%; min-height: 50px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  padding: 0 16px 0 44px; font-size: 1rem; -webkit-appearance: none;
}
.search::before { content: "🔍"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 1rem; opacity: .6; }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > .li { display: flex; align-items: center; gap: 12px; padding: 13px 14px; min-height: 58px; border-top: 1px solid var(--line); cursor: pointer; text-decoration: none; color: inherit; background: none; width: 100%; text-align: left; border-left: 0; border-right: 0; border-bottom: 0; }
.list > .li:first-child { border-top: 0; }
.list > .li:active { background: #f6f8fb; }
.li .lt { flex: 1; min-width: 0; }
.li .lt b { display: block; font-weight: 700; overflow-wrap: anywhere; }
.li .lt span { display: block; font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }
.li .ic { font-size: 1.4rem; width: 32px; text-align: center; }
.li .chev { color: var(--muted); }
.pill { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #eef1f5; color: var(--muted); white-space: nowrap; }
.pill.ok { background: #e7f6ec; color: var(--ok); }
.pill.warn { background: var(--warn-weak); color: var(--warn); }
.pill.danger { background: var(--danger-weak); color: var(--danger); }
.pill.accent { background: var(--accent-weak); color: var(--accent); }

/* ── フォーム ── */
.form .f { margin-bottom: 14px; }
.form label.l { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 6px; }
.form .hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.form input[type=text], .form input[type=email], .form input[type=url], .form input[type=number], .form input[type=date],
.form input[type=time], .form select, .form textarea {
  width: 100%; min-height: 48px; border: 1px solid #cfd6df; border-radius: 12px; padding: 10px 12px; background: #fff; font-size: 1rem;
}
.form textarea { min-height: 220px; resize: vertical; line-height: 1.6; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 0 12px; border: 1px solid #cfd6df; border-radius: 999px; background: #fff; font-size: .92rem; cursor: pointer; }
.checks input { width: 18px; height: 18px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.switch input { width: 48px; height: 28px; accent-color: var(--accent); }
.seg { display: flex; border: 1px solid #cfd6df; border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; min-height: 44px; border: 0; background: #fff; font-weight: 700; cursor: pointer; font-size: .9rem; }
.seg button + button { border-left: 1px solid #cfd6df; }
.seg button.on { background: var(--accent); color: #fff; }
.seg.deny button.on.d { background: var(--danger); }
.seg.deny button.on.a { background: var(--ok); }

/* ── タブ（横スクロールさせず折り返す） ── */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tabs a { padding: 9px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--text); font-weight: 600; font-size: .9rem; }
.tabs a.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── モーダル（スマホでは下から出るシート） ── */
.sheet-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--surface); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + var(--safe-b));
}
.sheet h2 { font-size: 1.1rem; margin: 0 0 14px; }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 18px; } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px + var(--safe-b)); transform: translateX(-50%); z-index: 60;
  background: #1f2937; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: .92rem; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.2);
}

/* ── 教材 ── */
.doc h2, .doc h3, .doc h4 { scroll-margin-top: 72px; line-height: 1.4; }
.doc h2 { font-size: 1.2rem; margin: 26px 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--accent-weak); }
.doc h3 { font-size: 1.05rem; margin: 20px 0 6px; }
.doc h4 { font-size: 1rem; margin: 16px 0 6px; }
.doc p { margin: 8px 0; overflow-wrap: anywhere; }
.doc ul { padding-left: 1.3em; }
.doc .hl { background: #fff1a8; border-radius: 4px; }
.doc .flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: #fff1a8; } to { background: transparent; } }
.toc a { display: block; padding: 8px 0; text-decoration: none; }
.toc a.l2 { padding-left: 14px; } .toc a.l3 { padding-left: 28px; } .toc a.l4 { padding-left: 42px; }
.hit { padding: 12px 14px; border-top: 1px solid var(--line); display: block; text-decoration: none; color: inherit; }
.hit:first-child { border-top: 0; }
.hit small { display: block; color: var(--muted); }
details.dcat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
details.dcat + details.dcat { margin-top: 10px; }
details.dcat > summary { list-style: none; padding: 14px; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 54px; }
details.dcat > summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
details.dcat[open] > summary::after { content: "▴"; }
details.dcat .list { border: 0; border-top: 1px solid var(--line); border-radius: 0; }

/* ── カレンダー ── */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-head .ttl { flex: 1; text-align: center; font-weight: 800; font-size: 1.1rem; }
.cal-head .nav { width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 1.1rem; cursor: pointer; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.month .dow { text-align: center; font-size: .75rem; font-weight: 700; color: var(--muted); padding: 6px 0; border-bottom: 1px solid var(--line); }
.month .dow.sun, .month .d.sun .n { color: var(--danger); }
.month .dow.sat, .month .d.sat .n { color: var(--accent); }
.month .d { min-height: 62px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); padding: 4px 3px; cursor: pointer; background: none; border-right: 0; border-bottom: 0; text-align: left; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.month .d:nth-child(7n + 1) { border-left: 0; }
.month .d.out { background: #fafbfc; }
.month .d.out .n { opacity: .4; }
.month .d .n { font-size: .82rem; font-weight: 700; }
.month .d.today .n { background: var(--accent); color: #fff !important; border-radius: 999px; padding: 0 6px; align-self: flex-start; }
.month .d.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.month .d .ev { font-size: .66rem; line-height: 1.25; border-radius: 4px; padding: 1px 3px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.month .d .more { font-size: .64rem; color: var(--muted); }
@media (min-width: 700px) { .month .d { min-height: 96px; } .month .d .ev { font-size: .74rem; } }
.evrow { display: flex; gap: 10px; align-items: stretch; padding: 12px 14px; border-top: 1px solid var(--line); cursor: pointer; background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; }
.evrow:first-child { border-top: 0; }
.evrow .bar { width: 5px; border-radius: 4px; flex: 0 0 5px; }
.evrow .tm { font-size: .82rem; color: var(--muted); min-width: 74px; }
.evrow .bd { flex: 1; min-width: 0; }
.evrow .bd b { display: block; overflow-wrap: anywhere; }
.dayhead { font-weight: 800; font-size: .92rem; margin: 16px 4px 6px; }
.dayhead.today { color: var(--accent); }
.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + 18px + var(--safe-b)); z-index: 25; width: 60px; height: 60px; border-radius: 999px;
  background: var(--accent); color: #fff; border: 0; font-size: 1.9rem; box-shadow: 0 6px 18px rgba(31,95,191,.35); cursor: pointer;
}
@media (min-width: 900px) { .fab { bottom: 28px; } }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.filters button { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .84rem; font-weight: 600; cursor: pointer; }
.filters button.on { background: var(--text); color: #fff; border-color: var(--text); }

/* ── 管理画面（PCでは一覧を表形式に） ── */
.admin-table .li .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
@media (min-width: 900px) {
  .admin-table .li { display: grid; grid-template-columns: 2fr 1.6fr 1fr 1fr auto; gap: 14px; }
}
.reorder { display: flex; flex-direction: column; gap: 2px; }
.reorder button { width: 40px; height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
pre.detail { white-space: pre-wrap; word-break: break-all; font-size: .75rem; background: #f6f8fb; border-radius: 8px; padding: 8px; max-height: 220px; overflow: auto; }

/* ── ログイン ── */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.login .logo { font-size: 3rem; }
.login h1 { font-size: 1.5rem; margin: 8px 0 4px; letter-spacing: .04em; }
.login .box { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 24px 18px; width: 100%; max-width: 380px; margin-top: 18px; }
.login .gbtn { display: flex; justify-content: center; min-height: 48px; margin: 14px 0 6px; }
.demo-switch { position: fixed; top: calc(8px + env(safe-area-inset-top, 0px)); right: 8px; z-index: 40; }
.demo-bar { background: #fef3c7; color: #78350f; font-size: .8rem; padding: 6px 12px; text-align: center; }
.demo-bar select { font-size: .85rem; min-height: 34px; border-radius: 8px; border: 1px solid #e5c97a; margin-left: 6px; max-width: 60vw; }
@media (min-width: 900px) { .demo-bar { margin-left: 92px; } }

/* スマホでは「既定・許可・禁止」を項目名の下の段に置き、名前を潰さない */
@media (max-width: 559px) {
  .list > .li > .seg { flex: 1 1 100%; min-width: 0 !important; }
  .list > .li > .lt { flex: 1 1 calc(100% - 80px); }
}

/* 前回の内容を表示しながら最新を確認している間の目印（画面上端の細い帯） */
html.syncing body::before { content: ''; position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100;
  background: linear-gradient(90deg, transparent, #3b82f6, transparent); background-size: 200% 100%; animation: dlpsync 1.1s linear infinite; }
@keyframes dlpsync { from { background-position: 100% 0; } to { background-position: -100% 0; } }
