:root {
  color-scheme: light;
  --ink: #151719;
  --muted: #5f6872;
  --line: #d9dee4;
  --panel: #ffffff;
  --page: #f5f7f8;
  --accent: #c91f34;
  --accent-dark: #991728;
  --gold: #b57922;
  --green: #1f7a4d;
  --blue: #2f6f9f;
  --shadow: 0 18px 40px rgba(30, 36, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 58px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-status {
  min-width: 170px;
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.icon-button,
.text-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 22px;
}

.text-button {
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 700;
}

.text-button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.app-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.tab-button {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 800;
}

.tab-button.active {
  border-bottom-color: var(--accent);
  color: var(--ink);
}

.view-section[hidden] {
  display: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.stats-grid article {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stats-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
  line-height: 1;
}

.toolbar {
  display: grid;
  grid-template-columns: 1.6fr repeat(5, minmax(130px, 1fr));
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 12px;
}

label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

.content-grid {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.sidebar,
.task-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sidebar {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow: auto;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.section-heading p,
.section-heading span {
  color: var(--muted);
  font-size: 13px;
}

.task-heading {
  align-items: flex-start;
}

.client-groups {
  padding: 8px;
}

.client-group {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px;
  text-align: left;
}

.client-group:hover,
.client-group.active {
  background: #f0f3f5;
}

.client-group strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-group span {
  color: var(--muted);
  font-size: 13px;
}

.task-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.task-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.task-card.overdue {
  border-left-color: var(--accent);
}

.task-card.soon {
  border-left-color: var(--gold);
}

.task-card.done {
  opacity: 0.62;
}

.check-wrap {
  padding-top: 4px;
}

.check-wrap input {
  width: 24px;
  height: 24px;
  min-height: 24px;
  accent-color: var(--green);
}

.task-main {
  min-width: 0;
}

.task-title {
  font-size: 17px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.task-card.done .task-title {
  text-decoration: line-through;
}

.task-meta,
.task-notes {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  background: #f8fafb;
  font-size: 13px;
  font-weight: 700;
}

.inline-action {
  min-height: 26px;
  border: 1px solid var(--blue);
  border-radius: 999px;
  background: #fff;
  color: var(--blue);
  cursor: pointer;
  padding: 3px 9px;
  font-size: 13px;
  font-weight: 800;
}

.task-date {
  min-width: 112px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.task-date.overdue-text {
  color: var(--accent-dark);
}

.empty-state {
  padding: 48px 18px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state strong {
  color: var(--ink);
  margin-bottom: 5px;
}

.time-toolbar {
  display: grid;
  grid-template-columns: auto 180px 180px minmax(320px, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 12px;
}

.week-picker,
.time-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.week-picker > div {
  min-width: 190px;
  padding: 4px 0;
}

.week-picker span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.week-picker strong {
  display: block;
  font-size: 16px;
}

.time-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.time-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.time-summary-grid article,
.retainer-panel,
.timesheet-panel,
.archive-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.time-summary-grid article {
  min-height: 86px;
  padding: 16px;
}

.time-summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.time-summary-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.retainer-panel {
  margin-bottom: 12px;
}

.retainer-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}

.retainer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.7fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.retainer-row strong,
.retainer-row span {
  display: block;
}

.retainer-row span,
.retainer-hours span {
  color: var(--muted);
  font-size: 13px;
}

.retainer-hours {
  text-align: right;
}

.meter {
  height: 7px;
  border-radius: 999px;
  background: #e5e9ee;
  margin-top: 8px;
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.timesheet-panel {
  overflow: hidden;
  margin-bottom: 12px;
}

.timesheet-grid {
  display: grid;
  grid-template-columns: minmax(320px, 2fr) repeat(5, minmax(120px, 1fr)) 120px;
  overflow-x: auto;
}

.sheet-head,
.sheet-cell,
.sheet-total,
.sheet-foot,
.sheet-project {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-height: 62px;
  padding: 10px;
}

.sheet-head,
.sheet-foot {
  background: #f8fafb;
  font-size: 13px;
  font-weight: 900;
}

.sheet-project strong,
.sheet-project span {
  display: block;
}

.sheet-project span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.time-entry {
  min-height: 40px;
  border-color: #c3cee2;
}

.time-entry.invalid {
  border-color: var(--accent);
}

.sheet-total,
.sheet-foot {
  align-content: center;
  font-weight: 900;
}

.sheet-empty {
  grid-column: 1 / -1;
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

.archive-toolbar {
  display: grid;
  grid-template-columns: 150px 150px repeat(3, minmax(160px, 1fr));
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.archive-summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.archive-summary strong {
  font-size: 24px;
}

.archive-summary span {
  color: var(--muted);
  font-size: 14px;
}

.archive-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  padding: 12px;
}

.archive-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.archive-row strong,
.archive-row span {
  display: block;
}

.archive-row span {
  color: var(--muted);
  font-size: 13px;
}

.archive-row > div:last-child {
  text-align: right;
}

.log-dialog {
  width: min(720px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
  padding: 0;
}

.log-dialog::backdrop {
  background: rgba(20, 24, 30, 0.42);
}

.log-dialog form {
  padding: 18px;
}

.dialog-heading,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-heading {
  margin-bottom: 14px;
}

.dialog-heading p {
  color: var(--muted);
  font-weight: 800;
}

.dialog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dialog-grid .wide {
  grid-column: 1 / -1;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  resize: vertical;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-label input {
  width: 18px;
  min-height: 18px;
}

.check-label span {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

@media (max-width: 1100px) {
  .toolbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .time-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .archive-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .time-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: 280px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .sync-status {
    min-width: 0;
    text-align: left;
  }

  .stats-grid,
  .toolbar,
  .time-toolbar,
  .time-summary-grid,
  .retainer-list {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar label:first-child {
    grid-column: 1 / -1;
  }

  .task-card {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .task-date {
    grid-column: 2;
    text-align: left;
  }

  .retainer-row,
  .archive-row,
  .dialog-grid {
    grid-template-columns: 1fr;
  }

  .retainer-hours,
  .archive-row > div:last-child {
    text-align: left;
  }
}

@media (max-width: 480px) {
  .stats-grid,
  .toolbar,
  .time-toolbar,
  .time-summary-grid,
  .retainer-list,
  .archive-toolbar {
    grid-template-columns: 1fr;
  }

  .time-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
