/* ============================================================
   Nekotime — リッチ・モバイルファースト デザインシステム
   ============================================================ */
:root {
  --brand: #6d5efc;
  --brand-2: #8b7cff;
  --brand-ink: #4a3ecc;
  --grad: linear-gradient(135deg, #7c6bff 0%, #6d5efc 45%, #5b8def 100%);
  --grad-warm: linear-gradient(135deg, #ff9a6b 0%, #ff7eb3 100%);
  --grad-green: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  --grad-red: linear-gradient(135deg, #fb7185 0%, #ef4444 100%);
  --grad-amber: linear-gradient(135deg, #fcd34d 0%, #f59e0b 100%);

  --bg: #f2f3f9;
  --bg-2: #e9ebf5;
  --card: #ffffff;
  --card-2: #f7f8fc;
  --line: #e6e8f0;
  --text: #1a1d29;
  --muted: #7b8194;
  --muted-2: #a4aab8;
  --green: #10b981; --amber: #f59e0b; --red: #ef4444; --blue: #3b82f6;
  --radius: 18px; --radius-sm: 12px; --radius-lg: 26px;
  --shadow: 0 2px 8px rgba(30,32,60,.06), 0 8px 30px rgba(30,32,60,.06);
  --shadow-lg: 0 10px 40px rgba(80,70,200,.18);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --nav-h: 66px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117; --bg-2: #151824; --card: #1a1d2b; --card-2: #212536;
    --line: #2a2f42; --text: #eef0f7; --muted: #9aa0b4; --muted-2: #6b7288;
    --shadow: 0 2px 10px rgba(0,0,0,.4); --shadow-lg: 0 12px 44px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1117; --bg-2: #151824; --card: #1a1d2b; --card-2: #212536;
  --line: #2a2f42; --text: #eef0f7; --muted: #9aa0b4; --muted-2: #6b7288;
  --shadow: 0 2px 10px rgba(0,0,0,.4); --shadow-lg: 0 12px 44px rgba(0,0,0,.5);
}
:root[data-theme="light"] {
  --bg: #f2f3f9; --card: #fff; --line: #e6e8f0; --text: #1a1d29; --muted: #7b8194;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", Meiryo, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
a { color: var(--brand); text-decoration: none; }
.app { max-width: 640px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 20px); }

/* ---- ヘッダー ---- */
.appbar {
  position: sticky; top: 0; z-index: 30; padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.appbar .logo { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; font-size: 18px; box-shadow: var(--shadow-lg); }
.appbar h1 { font-size: 17px; margin: 0; font-weight: 800; letter-spacing: .01em; }
.appbar .sub { font-size: 11px; color: var(--muted); font-weight: 600; margin-top: -2px; }
.appbar .spacer { flex: 1; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); display: grid; place-items: center; cursor: pointer; font-size: 17px; }
.icon-btn:active { transform: scale(.94); }

.screen { padding: 16px 16px 0; animation: fade .28s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.screen[hidden] { display: none; }

/* ---- カード ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card.pad-lg { padding: 22px; }
.card-title { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 800; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.card-title .chip { margin-left: auto; text-transform: none; letter-spacing: 0; }

/* ---- ヒーロー打刻カード ---- */
.hero {
  background: var(--grad); color: #fff; border: none; border-radius: var(--radius-lg);
  padding: 26px 22px; box-shadow: var(--shadow-lg); position: relative; overflow: hidden; margin-bottom: 18px;
}
.hero::after { content: ""; position: absolute; inset: -40% -20% auto auto; width: 240px; height: 240px; background: radial-gradient(circle, rgba(255,255,255,.25), transparent 70%); }
.hero .who { font-size: 13px; opacity: .9; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.hero .clock { font-size: 52px; font-weight: 800; letter-spacing: .01em; font-variant-numeric: tabular-nums; margin: 6px 0 0; text-shadow: 0 2px 10px rgba(0,0,0,.12); }
.hero .date { font-size: 13px; opacity: .92; font-weight: 600; }
.hero .statepill { display: inline-flex; align-items: center; gap: 7px; margin-top: 14px; background: rgba(255,255,255,.2); padding: 7px 15px; border-radius: 999px; font-weight: 800; font-size: 13px; backdrop-filter: blur(4px); }
.hero .statepill .dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(255,255,255,.28); }
.hero.working .statepill .dot { background: #a7f3d0; box-shadow: 0 0 0 4px rgba(167,243,208,.35); animation: pulse 1.6s infinite; }
.hero.break .statepill .dot { background: #fde68a; box-shadow: 0 0 0 4px rgba(253,230,138,.35); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ---- 打刻ボタン ---- */
.punch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.punch {
  border: none; border-radius: var(--radius); padding: 18px 14px; cursor: pointer;
  color: #fff; font-weight: 800; font-size: 16px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  box-shadow: var(--shadow); transition: transform .12s, opacity .2s, filter .2s; position: relative; overflow: hidden;
}
.punch .ic { font-size: 24px; }
.punch .sub { font-size: 11px; font-weight: 600; opacity: .9; }
.punch:active { transform: scale(.96); }
.punch.in { background: var(--grad-green); } .punch.out { background: var(--grad-red); }
.punch.bs { background: var(--grad-amber); } .punch.be { background: linear-gradient(135deg,#94a3b8,#64748b); }
.punch:disabled { filter: grayscale(.7) opacity(.45); cursor: not-allowed; box-shadow: none; }

/* ---- スタッツ ---- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(0,1fr)); gap: 10px; }
.stat { background: var(--card-2); border-radius: var(--radius-sm); padding: 14px; text-align: center; border: 1px solid var(--line); }
.stat .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11px; color: var(--muted); font-weight: 700; margin-top: 2px; }
.stat.grad { background: var(--grad); color: #fff; border: none; }
.stat.grad .l { color: rgba(255,255,255,.85); }

/* ---- タイムライン ---- */
.timeline { position: relative; padding-left: 4px; }
.tl-item { display: flex; gap: 12px; padding: 8px 0; align-items: center; }
.tl-item .tl-dot { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-size: 14px; color: #fff; flex: 0 0 auto; }
.tl-item .tl-dot.in { background: var(--green); } .tl-item .tl-dot.out { background: var(--red); }
.tl-item .tl-dot.bs { background: var(--amber); } .tl-item .tl-dot.be { background: #64748b; }
.tl-item .tl-time { font-weight: 800; font-variant-numeric: tabular-nums; }
.tl-item .tl-label { font-size: 12px; color: var(--muted); }

/* ---- フォーム ---- */
label { display: block; font-size: 12px; color: var(--muted); font-weight: 700; margin: 12px 0 5px; }
input, select, textarea {
  width: 100%; padding: 12px 13px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  font-size: 16px; font-family: inherit; background: var(--card); color: var(--text); transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.field-row { display: flex; gap: 10px; } .field-row > div { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 13px 18px; border: none; border-radius: var(--radius-sm); font-size: 15px; font-weight: 800; cursor: pointer; background: var(--grad); color: #fff; box-shadow: var(--shadow); transition: transform .12s, filter .15s; width: 100%; }
.btn:active { transform: scale(.97); } .btn:disabled { filter: grayscale(.5) opacity(.5); }
.btn.ghost { background: var(--card-2); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.btn.sm { padding: 8px 12px; font-size: 13px; width: auto; border-radius: 10px; }
.btn.green { background: var(--grad-green); } .btn.red { background: var(--grad-red); } .btn.amber { background: var(--grad-amber); }
.btn.block { width: 100%; }

/* ---- セグメント / タブ ---- */
.seg { display: flex; background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; overflow-x: auto; scrollbar-width: none; margin-bottom: 14px; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1 0 auto; border: none; background: transparent; color: var(--muted); font-weight: 800; font-size: 13px; padding: 9px 12px; border-radius: 9px; cursor: pointer; white-space: nowrap; transition: .15s; }
.seg button.active { background: var(--card); color: var(--brand-ink); box-shadow: var(--shadow); }

/* ---- ピル / バッジ ---- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 3px 10px; border-radius: 999px; font-weight: 800; }
.pill.pending { background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber); }
.pill.approved { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.pill.rejected { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); }
.pill.open { background: color-mix(in srgb, var(--blue) 18%, transparent); color: var(--blue); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 3px 9px; border-radius: 8px; background: var(--card-2); border: 1px solid var(--line); color: var(--muted); font-weight: 700; }

/* ---- リスト項目 ---- */
.item { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item .av { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; color: #fff; background: var(--grad); flex: 0 0 auto; font-size: 15px; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 700; }
.item .s { font-size: 12px; color: var(--muted); }
.item .r { text-align: right; }

/* ---- テーブル ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
th, td { padding: 10px 11px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { font-size: 11px; color: var(--muted); font-weight: 800; background: var(--card-2); position: sticky; top: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.total td { font-weight: 800; background: var(--card-2); }

/* ---- ボトムナビ ---- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 640px; z-index: 40;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar button { flex: 1; border: none; background: transparent; color: var(--muted); font-size: 10.5px; font-weight: 800; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; padding-top: 10px; transition: color .15s; }
.tabbar button .ic { font-size: 21px; transition: transform .18s; }
.tabbar button.active { color: var(--brand); }
.tabbar button.active .ic { transform: translateY(-2px) scale(1.08); }

/* ---- トースト ---- */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); transform: translate(-50%, 20px); background: #1f2333; color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 700; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; z-index: 60; transition: .25s; max-width: 88%; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #dc2626; } .toast.ok { background: #059669; }

/* ---- ボトムシート / モーダル ---- */
.sheet-bg { position: fixed; inset: 0; background: rgba(15,17,23,.5); z-index: 70; opacity: 0; pointer-events: none; transition: .2s; backdrop-filter: blur(2px); }
.sheet-bg.show { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 50%; bottom: 0; transform: translate(-50%, 100%); width: 100%; max-width: 640px; background: var(--card); border-radius: 22px 22px 0 0; z-index: 71; padding: 8px 18px calc(24px + var(--safe-b)); transition: transform .28s cubic-bezier(.2,.9,.3,1); max-height: 88vh; overflow-y: auto; }
.sheet.show { transform: translate(-50%, 0); }
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 12px; }
.sheet h3 { margin: 0 0 4px; font-size: 18px; font-weight: 800; }

.muted { color: var(--muted); } .center { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; font-size: 14px; }
.empty .ic { font-size: 34px; display: block; margin-bottom: 8px; opacity: .5; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.row-gap { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.skeleton { background: linear-gradient(90deg, var(--card-2) 25%, var(--line) 50%, var(--card-2) 75%); background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: 8px; height: 60px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---- バーチャート（inline） ---- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 10px; background: var(--card-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--grad); border-radius: 999px; transition: width .6s cubic-bezier(.2,.9,.3,1); }

/* 管理画面（広め） */
.wide { max-width: 1100px; }
@media (min-width: 760px) {
  .wide .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .wide .grid2 > * { margin-bottom: 0; }
}
