:root {
  --bg: #f6f6f4;
  --card: #ffffff;
  --ink: #1a1c1e;
  --ink-2: #5c6066;
  --ink-3: #9a9ea6;
  --line: #e7e7e3;
  --accent: #2e5cff;
  --accent-soft: #eef2ff;
  --green: #1a9e6c;
  --green-soft: #e7f6ef;
  --amber: #b97a0a;
  --amber-soft: #fdf3df;
  --red: #d64545;
  --red-soft: #fdeeee;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 22, 26, .04), 0 8px 24px rgba(20, 22, 26, .05);
  --font: "Inter", "Noto Sans JP", system-ui, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
}
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 40px 32px 32px;
}
.brand { text-align: center; margin-bottom: 28px; }
.brand h1 { font-size: 20px; font-weight: 700; letter-spacing: .02em; margin-top: 14px; }
.brand p { font-size: 13px; margin-top: 4px; }
.brand-mark {
  width: 52px; height: 52px; margin: 0 auto;
  background: linear-gradient(135deg, #38a8f8, #2e5cff);
  color: #fff; font-size: 24px; font-weight: 700;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
}
.brand-mark.sm { width: 30px; height: 30px; font-size: 15px; border-radius: 9px; display: inline-flex; margin: 0 10px 0 0; }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 14px; }
input, select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 11px 14px;
  font: inherit; font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 92, 255, .12);
}
.error { color: var(--red); font-size: 13px; margin: 4px 0 12px; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-size: 14px; font-weight: 600;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  transition: background .15s, transform .05s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
a.btn { text-decoration: none; display: inline-block; }
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #33363a; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: #244ee0; }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-outline:hover:not(:disabled) { background: #f4f4f2; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(0,0,0,.05); color: var(--ink); }
.btn-danger { background: #fff; border-color: var(--line); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: var(--red-soft); border-color: #f2c7c7; }
.btn-block { width: 100%; padding: 12px; }
.btn-sm { font-size: 13px; padding: 7px 12px; border-radius: 8px; }

/* ---------- layout ---------- */
.topbar {
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex; align-items: center; gap: 24px;
}
.brand-sm { font-weight: 700; font-size: 15px; white-space: nowrap; display: flex; align-items: center; }
.nav { display: flex; gap: 2px; flex: 1; }
.nav a, .nav-mobile a {
  text-decoration: none;
  color: var(--ink-2);
  font-size: 14px; font-weight: 500;
  padding: 7px 13px;
  border-radius: 9px;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav a:hover { color: var(--ink); background: rgba(0,0,0,.04); }
.nav a.active, .nav-mobile a.active { color: var(--ink); background: rgba(0,0,0,.07); font-weight: 600; }
.nav-sep { width: 1px; height: 18px; background: var(--line); margin: auto 8px; }
.user-menu { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0; }
.user-menu .btn { white-space: nowrap; }
.user-name { font-size: 13px; color: var(--ink-2); white-space: nowrap; }

.nav-mobile { display: none; }

.main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.page-title { font-size: 21px; font-weight: 700; letter-spacing: .01em; }
.page-sub { color: var(--ink-2); font-size: 13.5px; margin-top: 2px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

/* ---------- punch screen ---------- */
.punch-hero { text-align: center; padding: 44px 24px 40px; }
.punch-date { color: var(--ink-2); font-size: 14px; font-weight: 500; }
.punch-clock {
  font-size: clamp(56px, 14vw, 84px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
  line-height: 1.15;
  margin: 4px 0 6px;
}
.punch-clock .sec { font-size: .45em; color: var(--ink-3); font-weight: 600; }
.status-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600;
  padding: 5px 14px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.status-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-chip.none { background: #f0f0ee; color: var(--ink-2); }
.status-chip.working { background: var(--green-soft); color: var(--green); }
.status-chip.break { background: var(--amber-soft); color: var(--amber); }
.status-chip.done { background: #f0f0ee; color: var(--ink-2); }

.punch-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  max-width: 420px; margin: 30px auto 0;
}
.punch-btn {
  font: inherit; font-size: 16px; font-weight: 700;
  padding: 20px 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.punch-btn small { display: block; font-size: 11.5px; font-weight: 500; color: var(--ink-3); margin-top: 2px; }
.punch-btn:disabled { opacity: .35; cursor: default; }
.punch-btn:not(:disabled):hover { border-color: var(--ink-3); }
.punch-btn:not(:disabled):active { transform: scale(.98); }
.punch-btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.punch-btn.primary small { color: rgba(255,255,255,.55); }
.punch-btn.primary:not(:disabled):hover { background: #33363a; }

.today-log { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 26px; }
.log-item {
  font-size: 12.5px; color: var(--ink-2);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 4px 12px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 12px; font-weight: 600;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid #f0f0ed; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
tr.weekend td.day { color: var(--red); }
tr.sat td.day { color: var(--accent); }
td.num, th.num { text-align: right; }
.today-row { background: var(--accent-soft); }

.badge {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
}
.badge.pending { background: var(--amber-soft); color: var(--amber); }
.badge.approved { background: var(--green-soft); color: var(--green); }
.badge.rejected { background: var(--red-soft); color: var(--red); }
.badge.working { background: var(--green-soft); color: var(--green); }
.badge.break { background: var(--amber-soft); color: var(--amber); }
.badge.done { background: #f0f0ee; color: var(--ink-2); }
.badge.none { background: #f0f0ee; color: var(--ink-3); }
.badge.admin-role { background: var(--accent-soft); color: var(--accent); }
.badge.inactive { background: var(--red-soft); color: var(--red); }
.badge.edited { background: var(--accent-soft); color: var(--accent); font-size: 10.5px; padding: 2px 7px; margin-left: 6px; }

/* ---------- month nav ---------- */
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-nav .label { font-size: 15px; font-weight: 700; min-width: 108px; text-align: center; font-variant-numeric: tabular-nums; }
.icon-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink-2);
  font-size: 15px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: #f4f4f2; color: var(--ink); }

/* ---------- stats ---------- */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stat {
  flex: 1; min-width: 140px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 18px;
}
.stat .k { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.stat .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .v small { font-size: 13px; color: var(--ink-3); font-weight: 600; }

/* ---------- misc ---------- */
.row-actions { display: flex; gap: 8px; }
.empty { text-align: center; color: var(--ink-3); padding: 36px 0; font-size: 14px; }
.form-row { display: flex; gap: 12px; }
.form-row label { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  font-size: 14px; font-weight: 500;
  padding: 11px 22px; border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
  z-index: 100;
  animation: toast-in .2s ease;
  max-width: calc(100vw - 40px);
}
.toast.err { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* modal */
.modal-back {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20,22,26,.4);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: #fff; border-radius: 18px;
  width: 100%; max-width: 420px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  max-height: 90dvh; overflow-y: auto;
}
.modal h3 { font-size: 16px; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .topbar-inner { height: 54px; gap: 12px; }
  .nav { display: none; }
  .nav-mobile {
    display: flex; gap: 2px;
    overflow-x: auto;
    padding: 0 12px 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-mobile::-webkit-scrollbar { display: none; }
  .main { padding: 20px 14px 48px; }
  .card { padding: 18px; border-radius: 14px; }
  .grid-2 { grid-template-columns: 1fr; }
  .punch-hero { padding: 30px 12px 28px; }
  .punch-actions { grid-template-columns: 1fr 1fr; gap: 10px; }
  .user-name { display: none; }
  .form-row { flex-direction: column; gap: 0; }
}
