:root {
  --navy: #0b2a4a; --navy-2: #143d66; --gold: #c9a227; --gold-soft: #f6efd9;
  --bg: #f5f6f8; --surface: #ffffff; --line: #e3e6eb; --text: #18212b; --muted: #687482;
  --ok: #1f7a4d; --ok-bg: #e5f4ec; --warn: #9a6a00; --warn-bg: #fbf1d6; --bad: #b42318; --bad-bg: #fde8e6;
  --info: #1d4f91; --info-bg: #e6eef9; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text); background: var(--bg); font-size: 15px; line-height: 1.45;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1 { font-size: 1.45rem; margin: 0 0 .15rem; color: var(--navy); }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; color: var(--navy); }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; }
p { margin: .3rem 0; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .hidden { display: none !important; }
a { color: var(--navy-2); }

/* buttons & inputs */
.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: .5rem .85rem;
  border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.btn:hover { border-color: #c5cbd3; } .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; } .btn-primary:hover { background: var(--navy-2); }
.btn-danger { color: var(--bad); } .btn-danger:hover { border-color: var(--bad); }
.btn-link { border: 0; background: none; color: var(--navy-2); padding-left: 0; }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; } .btn-block { width: 100%; justify-content: center; margin-top: .5rem; }
.icon-btn { border: 0; background: none; font-size: 1.4rem; cursor: pointer; color: inherit; line-height: 1; padding: .2rem .5rem; }
input, select, textarea { font: inherit; padding: .5rem .6rem; border: 1px solid #ccd2da; border-radius: 8px; background: #fff; width: 100%; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }
input[type=checkbox] { width: auto; accent-color: var(--navy); }
textarea { resize: vertical; }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .6rem; }
.field-label { font-size: .82rem; font-weight: 600; color: #3a4552; }
.hint { font-size: .78rem; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: .35rem; margin: .25rem .8rem .25rem 0; font-size: .9rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .9rem; }
.span2 { grid-column: span 2; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .5rem 0; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 140px; }
.w-sm { width: 110px !important; flex: 0 0 110px !important; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--navy), #061a30); }
.login-card { background: #fff; border-radius: 14px; padding: 2rem 1.6rem; width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.login-card h1 { margin-top: .8rem; }
.login-note { min-height: 1.3em; font-size: .88rem; color: var(--navy-2); margin-top: .8rem; }
.brand-mark { width: 52px; height: 52px; border-radius: 12px; background: var(--navy); color: var(--gold); display: grid; place-items: center;
  font-family: Georgia, serif; font-weight: 700; font-size: 1.3rem; letter-spacing: .02em; }
.brand-mark.sm { width: 32px; height: 32px; font-size: .85rem; border-radius: 8px; }

/* shell */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem; padding: .55rem 1rem;
  background: var(--navy); color: #fff; border-bottom: 3px solid var(--gold); }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 600; letter-spacing: .01em; }
.user { margin-left: auto; display: flex; gap: .6rem; align-items: center; }
.user .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.menu-btn { display: none; color: #fff; }
.layout { display: flex; min-height: calc(100vh - 54px); }
.nav { width: 210px; flex: 0 0 210px; background: var(--surface); border-right: 1px solid var(--line); padding: .8rem .5rem; display: flex; flex-direction: column; gap: 2px; }
.nav a { padding: .55rem .8rem; border-radius: 8px; text-decoration: none; color: #2b3642; font-weight: 500; }
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--gold-soft); color: var(--navy); box-shadow: inset 3px 0 0 var(--gold); }
.content { flex: 1; padding: 1.2rem 1.4rem 4rem; max-width: 1200px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.week-nav, .filters { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.week-nav input[type=date], .filters input[type=date] { width: auto; }
.filters select { width: auto; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card.error { color: var(--bad); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.subcard { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .5rem; }
.empty { color: var(--muted); font-style: italic; padding: .4rem 0; }
.note-bad { background: var(--bad-bg); color: var(--bad); padding: .45rem .7rem; border-radius: 8px; font-size: .9rem; }

/* badges */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #eef0f3; color: #3a4552; margin: 0 .25rem .15rem 0; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); } .badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); } .badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: #f0f1f3; color: var(--muted); }

/* status + stats */
.status-card { border-left: 4px solid var(--line); }
.status-submitted { border-left-color: var(--info); } .status-approved { border-left-color: var(--ok); } .status-rejected { border-left-color: var(--bad); }
.status-row { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; }
.status-row + .status-row { margin-top: .7rem; padding-top: .7rem; border-top: 1px dashed var(--line); }
.stats { display: flex; gap: 1.4rem; } .stats.wrap { flex-wrap: wrap; margin-bottom: .5rem; }
.stat { display: flex; flex-direction: column; } .stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stat-value { font-size: 1.1rem; font-weight: 700; color: var(--navy); }

/* days */
.days { display: flex; flex-direction: column; gap: .7rem; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: var(--shadow); }
.day.compact { box-shadow: none; padding: .6rem .8rem; margin-bottom: .5rem; }
.day-off { background: transparent; box-shadow: none; border-style: dashed; padding: .5rem 1rem; }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }
.day-head strong { margin-right: .5rem; }
.day-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.day-total.ok { color: var(--ok); } .day-total.short { color: var(--bad); }
.bar { height: 4px; background: #edf0f3; border-radius: 4px; margin: .5rem 0; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--gold); } .bar span.ok { background: var(--ok); }
.entries { display: flex; flex-direction: column; gap: .5rem; margin: .4rem 0; }
.entry { display: flex; justify-content: space-between; gap: .8rem; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; }
.entry-main { min-width: 0; flex: 1; }
.entry-sub { font-size: .85rem; color: #3a4552; }
.entry-remarks { font-size: .9rem; margin: .3rem 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry-side { display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; }
.entry-hours { font-weight: 700; font-size: 1.05rem; color: var(--navy); white-space: nowrap; }
.entry-actions { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.day-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; }

.summary .sum-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.sum-row { display: flex; justify-content: space-between; gap: .5rem; padding: .25rem 0; border-bottom: 1px solid #f0f2f4; font-size: .9rem; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: .5rem .55rem; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.data td { padding: .5rem .55rem; border-bottom: 1px solid #eef0f3; vertical-align: top; }
table.data tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.clickable { cursor: pointer; } table.data tr.clickable:hover td { background: var(--gold-soft); }

/* tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tab { border: 0; background: none; padding: .6rem .9rem; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.active { color: var(--navy); border-bottom-color: var(--gold); }

/* goals, ratings, groups */
.goal { border: 1px solid var(--line); border-radius: 8px; padding: .65rem .8rem; margin: .5rem 0; }
.goal-head { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.goal-actions { display: flex; gap: .35rem; margin-top: .4rem; flex-wrap: wrap; }
.stars { color: var(--gold); letter-spacing: 1px; white-space: nowrap; }
.rate-row { display: grid; grid-template-columns: 1.1fr .9fr 1.3fr 1.3fr auto; gap: .7rem; align-items: start; padding: .8rem 0; border-top: 1px solid var(--line); }
.rate-who { display: flex; flex-direction: column; gap: .15rem; }
.rate-row .btn { margin-top: 1.4rem; }
.group-block { padding: .6rem 0; border-top: 1px solid var(--line); }
.group-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: .25rem .7rem; font: inherit; font-size: .85rem; cursor: pointer; }
.chip.muted { color: var(--muted); text-decoration: line-through; }

/* modal + toast + loading */
.modal-overlay { position: fixed; inset: 0; background: rgba(8,20,36,.5); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 760px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 1rem 1.1rem; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .8rem 1.1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; transition: .25s; z-index: 80;
  background: var(--navy); color: #fff; padding: .7rem 1rem; border-radius: 10px; max-width: min(92vw, 560px); box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: .92rem; }
.toast.show { opacity: 1; transform: translate(-50%, 0); } .toast-error { background: var(--bad); }
.loading { display: flex; align-items: center; gap: .6rem; color: var(--muted); padding: 2rem 0; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--navy); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* mobile */
@media (max-width: 820px) {
  .menu-btn { display: block; }
  .user-name { display: none; }
  .nav { position: fixed; top: 54px; left: 0; bottom: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  body.nav-open .nav { transform: none; }
  .content { padding: 1rem 16px 5rem; }
  .form-grid { grid-template-columns: 1fr; } .span2 { grid-column: auto; }
  .summary .sum-grid { grid-template-columns: 1fr; }
  .stats { gap: 1rem; }
  .entry { flex-direction: column; } .entry-side { flex-direction: row; justify-content: space-between; align-items: center; }
  .rate-row { grid-template-columns: 1fr; } .rate-row .btn { margin-top: 0; }
  .modal-overlay { padding: 0; place-items: end stretch; }
  .modal { max-width: none; max-height: 92vh; border-radius: 14px 14px 0 0; }
  .page-head { align-items: flex-start; }
}
.trial { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; padding: .4rem 1rem; background: var(--gold-soft); border-bottom: 1px solid var(--line); font-size: .85rem; }
.pre { white-space: pre-wrap; font-size: .88rem; } .bad-text { color: var(--bad); font-weight: 600; } .clickable { cursor: pointer; } .pick { display: flex; justify-content: space-between; }
.group-block .entry { margin-top: .4rem; } .filters input[type=month] { width: auto; } .inline-form input[type=date] { flex: 0 1 150px; } .note-bad { margin-bottom: .8rem; }
.para { margin: .4rem 0; } .para p { margin: .1rem 0; }
