:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --line: #d7dde4;
  --text: #1e2a37;
  --muted: #6d7b8a;
  --accent: #0d76d8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 16px;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
}

.app {
  max-width: 1500px;
  margin: 0 auto;
}

.login-view {
  min-height: calc(100vh - 32px);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(460px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f6f9fc 100%);
  box-shadow: 0 18px 50px rgba(15, 34, 54, 0.08);
}

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

.login-card h1 {
  margin: 0 0 12px;
  font-size: 32px;
}

.login-message {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.5;
}

.login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 220px;
  height: 42px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.login-button[aria-disabled="true"] {
  opacity: 0.55;
  pointer-events: none;
}

.auth-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.auth-identity {
  font-size: 14px;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.tenant-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.tenant-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

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

.tenant-group select {
  min-width: 180px;
  height: 30px;
  border: 1px solid #cfd7e1;
  background: #fff;
  padding: 2px 8px;
  font: inherit;
}

.tenant-group button[hidden] {
  display: none;
}

.tab {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.tab.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.hidden {
  display: none !important;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.date-nav,
.actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.weekday-label {
  min-width: 88px;
  color: var(--muted);
  font-size: 13px;
}

.day-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -2px 0 10px;
}

.day-meta-row label {
  font-size: 13px;
  color: var(--muted);
}

.day-meta-row input {
  width: 300px;
  max-width: 100%;
  height: 30px;
  border: 1px solid #cfd7e1;
  padding: 2px 8px;
  background: #fff;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  height: 30px;
  padding: 0 10px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.sheet-wrap {
  border: 1px solid var(--line);
  background: var(--surface);
  overflow-x: auto;
}

.sheet {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

.sheet th,
.sheet td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 2px;
  vertical-align: middle;
}

.sheet th {
  background: #eef3f8;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  padding: 6px 4px;
}

.sheet input {
  width: 100%;
  min-width: 80px;
  border: 1px solid #cfd7e1;
  height: 28px;
  padding: 2px 6px;
  background: #fff;
}

.sheet td:nth-child(1),
.sheet td:nth-child(2),
.sheet td:nth-child(8) {
  width: 92px;
}

.sheet td:nth-child(7) {
  width: 220px;
}

.sheet th:last-child,
.sheet td:last-child {
  width: 78px;
}

.sheet .buttons {
  display: flex;
  gap: 2px;
  justify-content: center;
}

.sheet .buttons button {
  flex: 0 0 30px;
  width: 30px;
  padding: 0;
  height: 28px;
}

.sheet .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sheet .icon-button svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  pointer-events: none;
}

.day-sheet th:nth-child(1),
.day-sheet td:nth-child(1),
.day-sheet th:nth-child(2),
.day-sheet td:nth-child(2) {
  width: 72px;
}

.day-sheet th:nth-child(8),
.day-sheet td:nth-child(8) {
  width: 64px;
}

.day-sheet th:nth-child(3),
.day-sheet td:nth-child(3),
.day-sheet th:nth-child(4),
.day-sheet td:nth-child(4) {
  width: 120px;
}

.day-sheet th:nth-child(5),
.day-sheet td:nth-child(5) {
  width: 160px;
}

.day-sheet th:nth-child(9),
.day-sheet td:nth-child(9) {
  width: 72px;
}

.day-sheet td {
  padding: 0;
}

.day-sheet td.buttons {
  padding: 4px;
}

.day-sheet input {
  min-width: 0;
  height: 34px;
  border: 0;
  padding: 6px 8px;
  background: transparent;
}

.day-sheet input:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.day-sheet .duration-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 34px;
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
}

.duration.inferred-end {
  color: var(--muted);
}

.sheet tr.saving {
  background: #f6fbff;
}

@media (max-width: 900px) {
  .auth-bar,
  .tenant-bar,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .tenant-group,
  .date-nav,
  .actions {
    flex-wrap: wrap;
  }

  .tenant-group select,
  .day-meta-row input {
    width: 100%;
  }
}

.sheet tbody tr:hover,
.sheet tbody tr:focus-within {
  background: #edf4ff;
}

.sheet tr.save-error input {
  border-color: #cf3f3f;
}

.day-sheet tr.save-error input {
  box-shadow: inset 0 0 0 1px #cf3f3f;
}

.summary {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: baseline;
  padding: 8px 4px 0;
  font-size: 14px;
}

.summary strong {
  min-width: 60px;
  text-align: right;
}

.month-title {
  display: flex;
  gap: 8px;
  align-items: center;
}

.month-summary-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.month-work-locations {
  font-size: 13px;
  color: var(--muted);
}

.month-wrap {
  border: 1px solid var(--line);
  background: var(--surface);
}

.month-grid,
.month-grid-row {
  display: grid;
  grid-template-columns: 1fr 100px;
}

.month-grid-head {
  background: #eef3f8;
  font-weight: 600;
}

.month-grid-head > div {
  padding: 6px 8px;
  border-right: 1px solid var(--line);
}

.month-grid-head > div:last-child {
  border-right: none;
  text-align: right;
}

.month-grid-row > div {
  padding: 5px 8px;
  border-top: 1px solid var(--line);
}

.month-grid-row:hover > div {
  background: #edf4ff;
}

.month-grid-row > div:last-child {
  text-align: right;
  border-left: 1px solid var(--line);
}

.month-grid-row.level-client {
  font-weight: 600;
  background: #fbfcfd;
}

.month-grid-row.level-project {
  background: #fdfefe;
}

.month-grid-row.level-category {
  color: #334455;
}

.month-grid-row.level-description {
  color: #4f6072;
}

.month-grid-row.level-project .group-label {
  padding-left: 16px;
}

.month-grid-row.level-category .group-label {
  padding-left: 32px;
}

.month-grid-row.level-description .group-label {
  padding-left: 48px;
}

.summary-link {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  height: auto;
}

.month-detail {
  margin-top: 12px;
}

.month-detail-head {
  margin-bottom: 8px;
}

.month-detail .sheet td:nth-child(1) {
  width: 108px;
}

.month-detail .sheet td:nth-child(8) {
  width: 220px;
}

.month-detail .sheet td:nth-child(9) {
  width: 92px;
}

.month-detail .sheet td:last-child {
  width: 150px;
}

@media (max-width: 900px) {
  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .day-meta-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .day-meta-row input {
    width: 100%;
  }

  .sheet {
    font-size: 12px;
  }
}
