@font-face {
  font-family: Inter;
  src: url("/assets/fonts/inter-latin.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: Space Grotesk;
  src: url("/assets/fonts/space-grotesk-latin.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #172127;
  --muted: #708089;
  --line: #dbe3e6;
  --surface: #ffffff;
  --canvas: #f4f7f7;
  --teal: #12665f;
  --teal-soft: #e4f1ef;
  --blue-soft: #eaf1fa;
  --red: #a83932;
  --shadow: 0 8px 22px rgba(26, 47, 53, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, Arial, sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.brand,
.eyebrow {
  margin: 0;
  color: var(--teal);
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: linear-gradient(120deg, #eef5f4 0 54%, #f8fafb 54% 100%);
}

.login-panel {
  width: min(420px, 100%);
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1 { margin: 4px 0 8px; font-family: "Space Grotesk", sans-serif; font-size: 42px; }
.intro { margin: 0 0 28px; color: var(--muted); line-height: 1.5; }

label { display: grid; gap: 7px; color: #425158; font-size: 13px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfdadd;
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(18, 102, 95, 0.2); border-color: var(--teal); }
textarea { resize: vertical; }

button {
  min-height: 40px;
  border: 1px solid var(--teal);
  border-radius: 6px;
  padding: 8px 16px;
  color: #fff;
  background: var(--teal);
  font-weight: 700;
}
button:hover { filter: brightness(0.96); }
button.secondary, .icon-button { border-color: var(--line); color: var(--ink); background: #fff; }
button.danger { border-color: #e9cac7; color: var(--red); background: #fff; }
.login-panel label + button, .login-panel button + label { margin-top: 16px; }
.login-panel > button:last-of-type { width: 100%; margin-top: 22px; }

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  min-height: 72px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}
.topbar strong { display: block; margin-top: 2px; font-family: "Space Grotesk", sans-serif; font-size: 20px; }
.main-tabs { display: flex; align-self: stretch; }
.main-tabs button { min-width: 120px; border: 0; border-radius: 0; color: #53636b; background: transparent; }
.main-tabs button.active { border-bottom: 3px solid var(--teal); color: var(--teal); }
.account-area { display: flex; align-items: center; justify-content: flex-end; gap: 12px; color: var(--muted); font-size: 13px; }
.icon-button { width: 40px; padding: 7px; font-size: 20px; }

.workspace { width: min(1480px, calc(100% - 48px)); margin: 0 auto; padding: 34px 0 60px; }
.page-heading, .controls, .week-control, .export-menu, .heading-actions { display: flex; align-items: center; }
.page-heading { justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.heading-actions { gap: 10px; }
.page-heading h1 { margin: 4px 0 0; font-family: "Space Grotesk", sans-serif; font-size: 28px; }
.controls { justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.week-control { gap: 8px; }
.week-control strong { margin-left: 10px; }
.controls > label { width: min(320px, 45%); }
.export-menu { gap: 8px; }

.time-surface {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.week-summary { display: grid; grid-template-columns: repeat(8, minmax(90px, 1fr)); border-bottom: 1px solid var(--line); background: #f9fbfb; }
.summary-cell { min-height: 72px; padding: 12px; border-right: 1px solid var(--line); }
.summary-cell:last-child { border-right: 0; }
.summary-cell small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.summary-cell strong { display: block; margin-top: 7px; font-family: "Space Grotesk", sans-serif; font-size: 20px; }
.summary-cell.total { background: var(--teal-soft); }

.timesheet { overflow-x: auto; }
.timesheet table { width: 100%; min-width: 1040px; border-collapse: collapse; table-layout: fixed; }
.timesheet th, .timesheet td { height: 58px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 8px; text-align: center; }
.timesheet th { height: 46px; color: var(--muted); background: #fbfcfc; font-size: 12px; }
.timesheet th:first-child, .timesheet td:first-child { width: 300px; padding-left: 18px; text-align: left; }
.timesheet tr:last-child td { border-bottom: 0; }
.timesheet td:last-child, .timesheet th:last-child { border-right: 0; }
.row-title strong, .row-title small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title small { margin-top: 3px; color: var(--muted); }
.time-cell { width: 100%; min-height: 38px; border: 1px solid transparent; color: var(--muted); background: transparent; }
.time-cell:hover { border-color: #b8cfcc; background: #f2f8f7; }
.time-cell.has-time { color: var(--teal); background: var(--teal-soft); }
.time-cell small { display: block; font-size: 10px; font-weight: 500; }
.empty-state { padding: 44px; color: var(--muted); text-align: center; }

.report-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) minmax(240px, 2fr) auto;
  gap: 12px;
  align-items: end;
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); margin: 18px 0; border: 1px solid var(--line); background: #fff; }
.metric { padding: 20px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric small { color: var(--muted); }
.metric strong { display: block; margin-top: 7px; font-family: "Space Grotesk", sans-serif; font-size: 24px; }
.report-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(520px, 2fr); gap: 18px; }
.report-panel { overflow: hidden; border: 1px solid var(--line); background: #fff; }
.report-panel h2 { margin: 0; padding: 16px 18px; border-bottom: 1px solid var(--line); font-size: 16px; }
.breakdown-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 12px 18px; border-bottom: 1px solid #edf1f2; }
.breakdown-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-table-wrap { overflow: auto; max-height: 560px; }
.report-table { width: 100%; min-width: 780px; border-collapse: collapse; }
.report-table th, .report-table td { padding: 12px; border-bottom: 1px solid #edf1f2; text-align: left; font-size: 13px; }
.report-table th { position: sticky; top: 0; background: #f9fbfb; color: var(--muted); }

dialog { width: min(650px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 8px; box-shadow: 0 24px 70px rgba(15, 29, 34, 0.25); }
dialog::backdrop { background: rgba(26, 39, 43, 0.48); }
#entry-form { padding: 24px; }
.dialog-head, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-head { margin-bottom: 22px; }
.dialog-head h2 { margin: 3px 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.check-field { display: flex; align-items: center; gap: 8px; }
.check-field input { width: 18px; min-height: 18px; }
.dialog-actions { margin-top: 20px; }
.dialog-actions span { flex: 1; }
.status { min-height: 20px; margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.status.error { color: var(--red); }

@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr auto; padding: 0 18px; }
  .main-tabs { grid-column: 1 / -1; grid-row: 2; height: 48px; order: 3; }
  .topbar { padding-top: 10px; }
  .main-tabs button { flex: 1; }
  .workspace { width: min(100% - 24px, 1480px); padding-top: 24px; }
  .controls { align-items: stretch; flex-direction: column; }
  .controls > label { width: 100%; }
  .week-summary { grid-template-columns: repeat(4, 1fr); }
  .summary-cell:nth-child(4) { border-right: 0; }
  .summary-cell { border-bottom: 1px solid var(--line); }
  .report-filters { grid-template-columns: 1fr 1fr; }
  .query-field { grid-column: 1 / -1; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(2) { border-right: 0; }
  .metric { border-bottom: 1px solid var(--line); }
  .report-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .account-area span { display: none; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .week-control { flex-wrap: wrap; }
  .week-control strong { width: 100%; margin: 4px 0 0; }
  .week-summary { grid-template-columns: repeat(2, 1fr); }
  .summary-cell:nth-child(even) { border-right: 0; }
  .report-filters, .form-grid { grid-template-columns: 1fr; }
  .query-field, .form-grid .wide { grid-column: auto; }
  .export-menu { width: 100%; }
  .export-menu button { flex: 1; }
}
