:root {
  --honey: #f5a524;
  --honey-dark: #c97d06;
  --honey-soft: #fff4dc;
  --bg: #faf7f1;
  --surface: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #ece6da;
  --in: #16a34a;
  --in-soft: #dcfce7;
  --out: #e5484d;
  --out-soft: #ffe4e4;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(31, 36, 48, .04), 0 6px 24px rgba(31, 36, 48, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 15px;
}
a { color: var(--honey-dark); text-decoration: none; }
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; display: flex; align-items: center; gap: .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.text-in { color: var(--in); font-weight: 600; }

/* ---------- Layout */
.container { max-width: 1040px; margin: 0 auto; padding: 24px 16px 64px; }
.container.centered { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.grid-2 > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-warning { border-color: #f6d9a8; }
.card h2 + p { margin-top: 8px; }
.big-number { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); text-align: center; padding: 16px 0; margin: 0; }

/* ---------- Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 1.1rem; color: var(--ink); }
.brand-logo {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--honey-soft); font-size: 1.2rem;
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 550; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.active { background: var(--honey-soft); color: var(--honey-dark); }
.user-menu { display: flex; align-items: center; gap: 8px; }
.user-menu form { margin: 0; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 6px; }
.link-btn:hover { color: var(--out); }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #ffd27a, var(--honey));
  color: #5a3a00; font-weight: 700; font-size: .85rem;
}
.avatar-small { width: 28px; height: 28px; font-size: .72rem; vertical-align: middle; margin-right: 6px; }
.avatar-large { width: 64px; height: 64px; font-size: 1.3rem; }
.profile { display: flex; align-items: center; gap: 16px; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .user-menu { margin-left: auto; }
}

/* ---------- Flash messages */
.flashes { display: grid; gap: 8px; margin-bottom: 16px; width: 100%; max-width: 1040px; }
.flash { padding: 12px 16px; border-radius: 12px; font-weight: 500; border: 1px solid transparent; animation: slide .25s ease-out; }
.flash-success { background: var(--in-soft); color: #14532d; border-color: #bbf7d0; }
.flash-error { background: var(--out-soft); color: #7f1d1d; border-color: #fecaca; }
.flash-info { background: var(--honey-soft); color: #6b4300; border-color: #fde3a7; }
@keyframes slide { from { opacity: 0; transform: translateY(-6px); } }
.centered .flashes { max-width: 380px; }

/* ---------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; transition: .15s;
}
.btn-primary { background: var(--honey); color: #3b2600; }
.btn-primary:hover { background: #eb980f; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--honey); color: var(--honey-dark); }
.btn-danger { background: var(--out); color: #fff; }
.btn-danger:hover { background: #cf3338; }
.btn-danger-ghost { background: none; color: var(--out); border-color: #f6caca; }
.btn-danger-ghost:hover { background: var(--out-soft); }
.btn-small { padding: 6px 10px; font-size: .85rem; border-radius: 10px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--line); color: var(--ink); font-size: 1.3rem; background: var(--surface);
}
.icon-btn:hover { border-color: var(--honey); color: var(--honey-dark); }

/* ---------- Forms */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 550; font-size: .92rem; }
.form small { font-weight: 400; }
input, select {
  font: inherit; color: inherit; width: 100%;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
input:focus, select:focus { outline: none; border-color: var(--honey); box-shadow: 0 0 0 3px rgba(245, 165, 36, .2); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--honey-dark); }
.form label.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.form-card { max-width: 640px; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; }
.role-picker { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role-picker legend { font-weight: 550; font-size: .92rem; margin-bottom: 6px; }
.form .role-option {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px;
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
}
.role-option:has(input:checked) { border-color: var(--honey); background: var(--honey-soft); }
.role-option span { display: grid; gap: 2px; }
.role-option small { color: var(--muted); }
@media (max-width: 520px) { .role-picker { grid-template-columns: 1fr; } }

/* ---------- Login */
.login-card { width: 100%; max-width: 380px; text-align: center; padding: 32px 28px; }
.login-card .form { text-align: left; margin-top: 20px; }
.login-logo { font-size: 2.6rem; width: 72px; height: 72px; display: grid; place-items: center; margin: 0 auto 12px; background: var(--honey-soft); border-radius: 22px; }

/* ---------- Punch card */
.punch-card { text-align: center; padding: 32px 20px 28px; position: relative; overflow: hidden; }
.punch-card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: radial-gradient(circle at 50% 0, var(--honey-soft), transparent 60%);
}
.punch-card > * { position: relative; }
.greeting { margin: 0; font-size: 1.1rem; font-weight: 600; }
.clock { font-size: clamp(3rem, 12vw, 4.6rem); font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; margin-top: 6px; }
.date-line { margin-bottom: 24px; }
.punch-form { display: grid; justify-items: center; gap: 16px; margin: 0; }
.punch-btn {
  width: 200px; height: 200px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-content: center; gap: 4px;
  color: #fff; font: inherit; font-size: 1.2rem; font-weight: 700; line-height: 1.2;
  transition: transform .12s, box-shadow .2s;
}
.punch-btn:active { transform: scale(.96); }
.punch-btn:disabled { opacity: .7; cursor: progress; }
.punch-icon { font-size: 2.2rem; line-height: 1; }
.punch-in {
  background: linear-gradient(145deg, #34d399, var(--in));
  box-shadow: 0 0 0 10px var(--in-soft), 0 14px 30px rgba(22, 163, 74, .35);
}
.punch-in:hover { box-shadow: 0 0 0 14px var(--in-soft), 0 18px 36px rgba(22, 163, 74, .4); }
.punch-out {
  background: linear-gradient(145deg, #fb7185, var(--out));
  box-shadow: 0 0 0 10px var(--out-soft), 0 14px 30px rgba(229, 72, 77, .35);
}
.punch-out:hover { box-shadow: 0 0 0 14px var(--out-soft), 0 18px 36px rgba(229, 72, 77, .4); }

.status { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-weight: 500; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: #c4c8cf; }
.status-in { color: #15803d; }
.status-in .dot { background: var(--in); box-shadow: 0 0 0 0 rgba(22, 163, 74, .5); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); } }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.timeline li { display: flex; align-items: center; gap: 8px; }
.timeline .right { margin-left: auto; font-variant-numeric: tabular-nums; }
.arrow { color: var(--muted); }

/* ---------- Chips & badges */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px;
  font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
  background: #f3f4f6; color: var(--ink);
}
.chip-in { background: var(--in-soft); color: #166534; }
.chip-out { background: var(--out-soft); color: #991b1b; }
.chip-range { background: var(--honey-soft); color: #7a4b00; }
.chip-open { background: var(--in-soft); color: #166534; }
a.chip:hover { outline: 2px solid var(--honey); }
.chip-edited { border: 1px dashed var(--honey-dark); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 650; background: #f3f4f6; color: var(--muted); }
.badge-admin { background: #ede9fe; color: #5b21b6; }
.badge-employee { background: var(--honey-soft); color: #7a4b00; }

/* ---------- Recap */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 12px 16px; }
.segmented { display: inline-flex; padding: 4px; background: var(--bg); border-radius: 12px; border: 1px solid var(--line); }
.segmented a { padding: 6px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.segmented a.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.period-nav { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.period-label { font-weight: 650; }
.filter { margin: 0; min-width: 200px; }
.filter select { padding: 8px 10px; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin: 16px 0; }
.summary-grid .card { margin: 0; }
.summary { display: grid; gap: 4px; padding: 16px; color: var(--ink); transition: .15s; }
a.summary:hover { border-color: var(--honey); transform: translateY(-1px); }
.summary-who { display: flex; align-items: center; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-total { font-size: 1.6rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.summary-grand { background: linear-gradient(135deg, #fff8e6, var(--honey-soft)); border-color: #f6d9a8; }

.emp-block { scroll-margin-top: 80px; }

/* ---------- Tables */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: #fffcf5; }
.table tfoot td { font-weight: 700; border-bottom: 0; padding-top: 14px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.row-muted td { opacity: .55; }
.icon-btn { flex: none; }
@media (max-width: 600px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .segmented { align-self: center; }
  .period-nav { justify-content: space-between; flex-wrap: wrap; }
  .period-label { flex: 1; text-align: center; font-size: .92rem; }
  .period-nav .btn-small { flex-basis: 100%; }
  .filter { min-width: 0; }
}

/* ---------- Leaves */
.nav a { white-space: nowrap; }
.nav-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 2px; border-radius: 999px; background: var(--out); color: #fff; font-size: .72rem; font-weight: 700; }
.badge-pending { background: var(--honey-soft); color: #7a4b00; }
.badge-approved { background: var(--in-soft); color: #166534; }
.badge-refused { background: var(--out-soft); color: #991b1b; }
.account-email { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }

.leaves-layout { margin-top: 0; align-items: start; }
.leave-form { margin-top: 14px; }
.leave-form label { align-content: start; }
.segmented-input { justify-self: start; }
.segmented-input label { display: block; padding: 6px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; cursor: pointer; }
.segmented-input input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-input label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.half-picker { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; align-content: start; }
.half-picker legend { font-weight: 550; font-size: .92rem; margin-bottom: 6px; padding: 0; }
.leave-form .only-half { display: none; }
.leave-form:has(input[name=kind][value=half]:checked) .only-half { display: revert; }
.leave-form:has(input[name=kind][value=half]:checked) .half-picker { display: flex; }
.leave-form:has(input[name=kind][value=half]:checked) .only-days { display: none; }

.leave-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; }
.leave-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.leave-list li:first-child { border-top: 0; padding-top: 0; }
.leave-list li.row-muted { opacity: .6; }
.leave-list form { margin: 0; }
.leave-main { flex: 1; min-width: 200px; }
.leave-main .summary-who { margin-bottom: 4px; }
.decide-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.decide-form input { width: 220px; padding: 6px 10px; }
.btn-approve { background: var(--in); color: #fff; }
.btn-approve:hover { background: #128a3e; }

.calendar-card { padding: 12px; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-head { text-align: center; font-size: .78rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 4px 0; }
.cal-day { min-height: 92px; padding: 6px; border-radius: 10px; background: var(--bg); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day.is-weekend { background: #f3efe6; }
.cal-day.is-out { opacity: .4; }
.cal-day.is-today { box-shadow: inset 0 0 0 2px var(--honey); }
.cal-num { font-size: .8rem; font-weight: 650; color: var(--muted); }
.is-today .cal-num { color: var(--honey-dark); }
.cal-leave { display: flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 6px; font-size: .76rem; font-weight: 600; min-width: 0; }
.cal-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-part { margin-left: auto; font-weight: 500; opacity: .75; flex: none; }
.leave-approved { background: var(--in-soft); color: #166534; }
.leave-pending { background: repeating-linear-gradient(135deg, var(--honey-soft) 0 6px, #ffe9b8 6px 12px); color: #7a4b00; border: 1px dashed var(--honey-dark); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 12px; align-items: center; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend .cal-leave { width: 22px; height: 14px; padding: 0; }
@media (max-width: 600px) {
  .cal-day { min-height: 64px; padding: 4px; }
  .cal-leave { padding: 1px 3px; font-size: .68rem; }
  .decide-form input { width: 100%; }
}
