:root {
  --navy: #0b1f33;
  --navy-2: #143451;
  --blue: #2e7df6;
  --blue-soft: #eaf2ff;
  --teal: #19aeb3;
  --teal-soft: #e9f9f8;
  --red: #d63649;
  --red-soft: #fff0f2;
  --gold: #e8a317;
  --bg: #f3f6f9;
  --card: #ffffff;
  --text: #14212f;
  --muted: #6b7a89;
  --line: #dce4eb;
  --shadow: 0 12px 30px rgba(11, 31, 51, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 6%, rgba(25,174,179,.08), transparent 24%),
    var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { display: block; }

.app-shell { min-height: 100vh; padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 84px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  color: white;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  box-shadow: 0 8px 22px rgba(11,31,51,.16);
}
.topbar-copy { min-width: 0; }
.topbar h1 { margin: 2px 0 0; font-size: 24px; }
.topbar-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 9px; }
.screen-pictogram {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.24);
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
.eyebrow, .label { margin: 0; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.eyebrow { color: #93b8d8; }
.label { color: var(--blue); }
.year-select {
  min-width: 86px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 12px;
  padding: 10px 10px;
  color: white;
  background: rgba(255,255,255,.1);
  font-weight: 800;
}
.year-select option { color: var(--text); }

main { width: min(1080px, 100%); margin: 0 auto; padding: 16px; }
.view { display: none; }
.view.active { display: block; }
.panel, .hero-card {
  background: var(--card);
  border: 1px solid rgba(220,228,235,.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { position: relative; overflow: hidden; margin-bottom: 16px; padding: 18px; }
.pictogram-panel { isolation: isolate; }
.panel-pictogram {
  position: absolute;
  right: -18px;
  top: -14px;
  z-index: -1;
  width: 132px;
  height: 132px;
  object-fit: cover;
  border-radius: 30px;
  opacity: .07;
  transform: rotate(6deg);
  pointer-events: none;
}
.hero-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
  padding: 22px;
  color: white;
  border: none;
  background: linear-gradient(145deg, #0b1f33, #164d75);
}
.hero-content { position: relative; z-index: 1; }
.hero-pictogram { width: 190px; height: 190px; right: -26px; top: -42px; opacity: .17; }
.hero-heading, .section-heading, .progress-meta, .inline-heading, .project-row, .entry-row, .switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.hero-heading h2, .section-heading h2 { margin: 4px 0 0; font-size: 20px; }
.hero-card .label { color: #82c1ee; }
.progress-percent { font-size: 24px; font-weight: 900; }
.progress-track { height: 15px; margin: 22px 0 10px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.18); }
.progress-fill { width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #33c6b7, #70dfcc); transition: width .35s ease; }
.hero-card.complete { background: linear-gradient(145deg, #681d2b, var(--red)); }
.hero-card.complete .progress-fill { background: white; }
.progress-meta { color: #d5e2ec; font-size: 13px; }
.progress-meta strong { color: white; }
.overtime-panel { display: flex; justify-content: space-between; margin-top: 18px; padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.14); }

.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.metric-card { position: relative; overflow: hidden; min-height: 132px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: var(--shadow); }
.metric-card p { position: relative; z-index: 1; margin: 0; color: var(--muted); font-size: 13px; }
.metric-card strong { position: relative; z-index: 1; display: block; margin: 10px 0 4px; font-size: 28px; }
.metric-card span { position: relative; z-index: 1; color: var(--muted); font-size: 12px; }
.metric-icon { position: absolute; right: -9px; bottom: -10px; width: 82px; height: 82px; object-fit: cover; border-radius: 20px; opacity: .16; }

.section-heading { position: relative; z-index: 1; margin-bottom: 18px; justify-content: flex-start; }
.section-heading.with-icon { align-items: center; }
.heading-copy { display: flex; align-items: center; gap: 12px; }
.section-icon { flex: 0 0 auto; width: 48px; height: 48px; object-fit: cover; border-radius: 14px; border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(11,31,51,.08); }
.text-button { border: 0; color: var(--blue); background: transparent; font-weight: 800; }

.monthly-cards { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-bottom: 16px; }
.month-card { min-height: 112px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(145deg, #fff, #f8fbfd); }
.month-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.month-card-head strong { font-size: 14px; }
.month-card-head span { color: var(--muted); font-size: 11px; }
.month-card-days { display: block; margin-top: 12px; font-size: 25px; font-weight: 900; }
.month-card-meta { margin-top: 3px; color: var(--muted); font-size: 12px; }
.month-card-meter { height: 6px; margin-top: 10px; overflow: hidden; border-radius: 99px; background: #e9eef3; }
.month-card-meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--blue)); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: white; }
table { width: 100%; min-width: 480px; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: right; font-size: 13px; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); background: #f8fafc; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
tbody tr:last-child td { border-bottom: 0; }

.project-breakdown { display: grid; gap: 14px; }
.project-stat { overflow: hidden; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.93); }
.project-stat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.project-stat-head strong { font-size: 16px; }
.project-total { text-align: right; }
.project-total strong { display: block; font-size: 16px; }
.project-total span { color: var(--muted); font-size: 11px; }
.project-track { height: 9px; overflow: hidden; border-radius: 99px; background: #edf1f5; }
.project-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--blue)); }
.project-stat-meta { display: flex; flex-wrap: wrap; justify-content: flex-start; column-gap: 22px; row-gap: 8px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.project-month-scroll { overflow: visible; margin: 14px 0 0; padding: 0; }
.project-month-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; min-width: 0; }
.project-month-cell { padding: 9px; border-radius: 11px; background: #f6f9fb; border: 1px solid #edf1f5; }
.project-month-cell strong { display: block; font-size: 12px; }
.project-month-cell span { display: block; margin-top: 5px; font-size: 12px; font-weight: 800; }
.project-month-cell small { color: var(--muted); font-size: 10px; }
.project-month-cell.empty { opacity: .55; }
.empty-state { padding: 24px 12px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 14px; }

.form-panel label { display: block; margin-bottom: 16px; font-weight: 800; font-size: 13px; }
.form-panel label small, label small { display: block; margin-top: 5px; color: var(--muted); font-weight: 500; }
input, select, textarea {
  width: 100%;
  margin-top: 7px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: white;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(46,125,246,.12); }
.switch-row { margin-bottom: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.9); }
.switch-row input { width: 52px; height: 28px; margin: 0; accent-color: var(--blue); }
.date-grid, .time-grid, .filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.calculated-box { display: flex; justify-content: space-between; gap: 12px; margin: 4px 0 18px; padding: 14px; border-radius: 14px; background: var(--blue-soft); }
.calculated-box span { color: var(--muted); font-size: 13px; }
.form-actions { display: flex; gap: 10px; }
.btn { min-height: 46px; padding: 11px 16px; border: 0; border-radius: 12px; font-weight: 900; }
.btn-primary { color: white; background: var(--blue); }
.btn-secondary { color: var(--navy); background: #eaf0f5; }
.btn-danger { color: var(--red); background: var(--red-soft); }
.form-actions .btn { flex: 1; }
.full-width { width: 100%; }
.inline-add, .inline-input { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 9px; align-items: end; margin: -7px 0 16px; }
.inline-add input, .inline-input input { margin: 0; }
.inline-add .btn, .inline-input .btn { min-height: 46px; }

.choice-fieldset { margin: 0 0 18px; padding: 0; border: 0; }
.choice-fieldset legend { margin-bottom: 8px; font-size: 13px; font-weight: 800; }
.choice-card { display: flex !important; align-items: center; gap: 12px; margin: 0 0 9px !important; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.92); }
.choice-card input { width: 22px; height: 22px; margin: 0; accent-color: var(--blue); }
.choice-card span { flex: 1; }
.choice-card strong { display: block; }
.editor-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }

.entry-list { display: grid; gap: 10px; }
.entry-row { padding: 13px 0; border-bottom: 1px solid var(--line); }
.entry-row:last-child { border-bottom: 0; }
.entry-main { min-width: 0; }
.entry-main strong { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.entry-main span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.entry-hours { flex: 0 0 auto; text-align: right; }
.entry-hours strong { display: block; }
.entry-hours span { color: var(--muted); font-size: 11px; }
.entry-actions { display: flex; gap: 7px; margin-top: 9px; }
.mini-btn { padding: 7px 10px; border: 0; border-radius: 9px; color: var(--navy); background: #edf2f6; font-size: 12px; font-weight: 800; }
.mini-btn.danger { color: var(--red); background: var(--red-soft); }
.summary-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.summary-pill { padding: 8px 11px; border-radius: 999px; color: var(--navy); background: var(--teal-soft); font-size: 12px; font-weight: 800; }
.project-row { padding: 11px 0; border-bottom: 1px solid var(--line); }
.project-row label { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 13px; }
.project-row input { width: 20px; height: 20px; margin: 0; accent-color: var(--blue); }
.button-stack { display: grid; gap: 10px; }
.file-button { display: flex; align-items: center; justify-content: center; }
.file-button input { display: none; }

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(14px);
  box-shadow: 0 -8px 24px rgba(11,31,51,.08);
}
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 58px; padding: 5px 2px; border: 0; border-radius: 12px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 800; }
.nav-item img { width: 28px; height: 28px; object-fit: cover; border-radius: 8px; filter: saturate(.75); opacity: .72; }
.nav-item.active { color: var(--blue); background: var(--blue-soft); }
.nav-item.active img { filter: none; opacity: 1; }
.toast { position: fixed; right: 16px; bottom: calc(94px + env(safe-area-inset-bottom)); left: 16px; z-index: 40; max-width: 480px; margin: auto; padding: 13px 16px; border-radius: 12px; color: white; background: var(--navy); box-shadow: 0 12px 30px rgba(11,31,51,.22); text-align: center; font-weight: 800; transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.hidden { display: none !important; }

body.days-only .hours-only-display { display: none !important; }
body.days-only .metric-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
body.days-only table { min-width: 390px; }

@media (min-width: 760px) {
  main { padding: 24px; }
  .metric-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
  body.days-only .metric-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .monthly-cards { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .project-month-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .panel { padding: 22px; }
  .topbar { padding-right: max(24px, calc((100vw - 1080px) / 2 + 24px)); padding-left: max(24px, calc((100vw - 1080px) / 2 + 24px)); }
}

@media (max-width: 520px) {
  .topbar h1 { font-size: 21px; }
  .eyebrow { font-size: 9px; }
  .screen-pictogram { flex-basis: 42px; width: 42px; height: 42px; }
  .year-select { min-width: 78px; padding: 9px 8px; }
  .date-grid, .time-grid, .filter-grid { grid-template-columns: 1fr; gap: 0; }
  .hero-heading { align-items: flex-start; }
  .progress-meta, .calculated-box { align-items: flex-start; flex-direction: column; }
  .project-stat-meta { align-items: flex-start; }
  .overtime-panel { align-items: flex-start; flex-direction: column; gap: 5px; }
  .entry-row { align-items: flex-start; }
  .entry-hours { min-width: 78px; }
  .inline-add, .inline-input { grid-template-columns: 1fr; }
  body.days-only .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .monthly-cards { grid-template-columns: repeat(2, minmax(0,1fr)); }
}


@media (max-width: 360px) {
  .project-month-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* v5 month drill-down and clickable month cards */
.month-card {
  width: 100%;
  border: 1px solid var(--line);
  color: inherit;
  background: rgba(255,255,255,.94);
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.month-card:active { transform: translateY(1px); }
.month-card:focus-visible { outline: 3px solid rgba(46,125,246,.24); outline-offset: 2px; }
body.modal-open { overflow: hidden; }
.month-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
  background: rgba(5,20,34,.58);
  backdrop-filter: blur(5px);
}
.month-detail-sheet {
  position: relative;
  width: min(100%, 620px);
  max-height: min(82vh, 760px);
  overflow-y: auto;
  padding: 20px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(5,20,34,.32);
}
.month-detail-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.month-detail-header h2 { margin: 3px 0 0; }
.icon-button {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  color: var(--navy);
  background: #edf2f6;
  font-size: 27px;
  line-height: 1;
}
.month-detail-projects { position: relative; z-index: 1; display: grid; gap: 10px; margin-top: 14px; }
.month-project-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.95);
}
.month-project-row strong { display: block; }
.month-project-row span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.month-project-total { flex: 0 0 auto; text-align: right; }

@media (min-width: 760px) {
  .month-detail-overlay { align-items: center; }
}
