:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-soft: #f0eee7;
  --ink: #1f2528;
  --muted: #687176;
  --line: #d9d4c9;
  --primary: #2f6f73;
  --primary-ink: #ffffff;
  --accent: #a85d2a;
  --danger: #b54747;
  --shadow: 0 12px 34px rgba(31, 37, 40, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

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

.auth-box h1,
.page-title h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.15;
}

.muted {
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

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

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

.textarea {
  min-height: 104px;
  resize: vertical;
}

.textarea.small {
  min-height: 72px;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 115, 0.16);
}

.compact {
  width: auto;
  min-width: 180px;
}

.compact-date {
  width: 150px;
}

.button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 40px;
  background: var(--surface-soft);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.button.primary {
  background: var(--primary);
  color: var(--primary-ink);
}

.button.warn {
  background: #f4dfcf;
  color: #653111;
}

.button.danger {
  background: #f6dddd;
  color: var(--danger);
}

.button.ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  display: inline-grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
}

.icon-button.ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.button:disabled {
  opacity: 0.5;
  cursor: default;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
}

.sidebar {
  background: #ebe7dc;
  border-right: 1px solid var(--line);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.page {
  padding: 22px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.topbar,
.toolbar,
.row,
.inline-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.timer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.timer-actions .button {
  width: 100%;
  min-height: 42px;
  white-space: normal;
  text-align: center;
}

.topbar {
  justify-content: space-between;
}

.page-title p {
  margin: 0;
}

.timer-card,
.panel,
.client-manager,
.reminder {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 5px 18px rgba(31, 37, 40, 0.07);
}

.manual-details summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin: 0;
}

.compact-toggle {
  min-height: 34px;
  padding: 7px 10px;
}

.manual-details[open] summary {
  margin-bottom: 12px;
}

.timer-card {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.timer-value {
  font-size: 42px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.active-client {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
  color: var(--muted);
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  flex: 0 0 auto;
}

.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.client-button {
  min-height: 76px;
  border: 1px solid rgba(31, 37, 40, 0.14);
  border-left: 8px solid var(--client-color);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  text-align: left;
  display: grid;
  align-content: center;
  gap: 4px;
}

.client-button.active {
  outline: 3px solid rgba(47, 111, 115, 0.18);
}

.client-button.study {
  border-left-color: #6f5ea8;
}

.client-button strong {
  overflow-wrap: anywhere;
}

.client-button small {
  color: var(--muted);
}

.client-manager,
.panel {
  padding: 16px;
}

.client-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.client-list-details {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.client-list-details summary {
  cursor: pointer;
  font-weight: 700;
}

.client-edit-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.client-list .client-edit-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.client-edit-row .button {
  min-width: 0;
}

.metric small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.panel h2,
.client-manager h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.tab {
  border: 0;
  border-radius: 6px;
  padding: 8px 12px;
  background: transparent;
}

.tab.active {
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(31, 37, 40, 0.08);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.metric {
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 12px;
}

.metric strong {
  display: block;
  font-size: 24px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.reminder {
  border-color: #e0bd8f;
  background: #fff8ee;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.hidden {
  display: none !important;
}

.error {
  color: var(--danger);
  min-height: 20px;
}

.status-line {
  min-height: 20px;
  font-size: 13px;
}

.success {
  color: var(--primary);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.settings-save {
  min-width: 150px;
  align-self: end;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 520px) {
  .page,
  .sidebar {
    padding: 12px;
  }

  .timer-value {
    font-size: 34px;
  }

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