:root {
  --bg: #f8f4ef;
  --card: rgba(255, 255, 255, 0.78);
  --text: #2d2a26;
  --muted: #756f67;
  --line: rgba(61, 49, 35, 0.12);
  --accent: #8f6f51;
  --accent-strong: #6f4f39;
  --danger: #b35b5b;
  --danger-bg: #fff1f1;
  --shadow: 0 24px 80px rgba(90, 66, 42, 0.12);
  --radius-xl: 28px;
  --focus: 0 0 0 4px rgba(143, 111, 81, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 224, 184, 0.8), transparent 36%),
    radial-gradient(circle at 88% 12%, rgba(213, 235, 219, 0.82), transparent 32%),
    radial-gradient(circle at 64% 92%, rgba(232, 214, 244, 0.7), transparent 36%),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 28px;
  z-index: 15;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(248, 244, 239, 0.98), rgba(248, 244, 239, 0));
  backdrop-filter: blur(8px);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 56px;
}

.timer-card {
  position: sticky;
  top: 12px;
  z-index: 20;
  overflow: visible;
  border-radius: var(--radius-xl);
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(20px);
}

.timer-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.54), transparent 48%),
    radial-gradient(circle at 94% 12%, rgba(255, 214, 158, 0.28), transparent 28%);
}

.timer-content {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  align-items: stretch;
}

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

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.task-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 15px 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  outline: none;
  transition: border 160ms ease, box-shadow 160ms ease, background 160ms ease;
  font-size: 18px;
}

.task-input:focus {
  border-color: rgba(143, 111, 81, 0.42);
  box-shadow: var(--focus);
  background: rgba(255, 255, 255, 0.92);
}

.task-input.invalid {
  border-color: rgba(179, 91, 91, 0.65);
  background: var(--danger-bg);
}

.error-message {
  min-height: 20px;
  margin-top: 8px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 650;
}

.offset-form {
  display: inline-flex;
  align-items: end;
  gap: 10px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid rgba(61, 49, 35, 0.1);
  border-radius: 20px;
  background: rgba(255, 250, 244, 0.52);
}

.time-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(90px, 1fr));
  gap: 10px;
  margin: 0;
  max-width: 280px;
}

.small-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.64);
  outline: none;
  transition: border 160ms ease, box-shadow 160ms ease;
}

.small-input:focus {
  border-color: rgba(143, 111, 81, 0.42);
  box-shadow: var(--focus);
}

.offset-tools {
  display: none;
  align-items: end;
}

.offset-tools.visible {
  display: flex;
}

.timer-panel {
  min-width: 0;
  border-radius: 24px;
  padding: 16px;
  background: rgba(255, 250, 244, 0.82);
  border: 1px solid rgba(61, 49, 35, 0.08);
}

.timer-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d8c7b6;
  box-shadow: 0 0 0 6px rgba(216, 199, 182, 0.22);
}

.status-dot.active {
  background: #4f8fbf;
  box-shadow: 0 0 0 7px rgba(79, 143, 191, 0.18);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    transform: scale(1.08);
  }
}

.timer-display {
  font-variant-numeric: tabular-nums;
  font-size: clamp(38px, 5vw, 56px);
  line-height: 1;
  letter-spacing: -0.055em;
  font-weight: 800;
  margin-bottom: 16px;
}

.primary-button {
  width: 100%;
  min-height: 48px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, #8f6f51, #6f4f39);
  box-shadow: 0 16px 36px rgba(111, 79, 57, 0.22);
  font-weight: 800;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 20px 40px rgba(111, 79, 57, 0.26);
}

.primary-button.stop {
  background: linear-gradient(135deg, #bb6b6b, #8e4e4e);
  box-shadow: 0 16px 36px rgba(142, 78, 78, 0.2);
}

.timer-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.timer-summary strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}

.list-section {
  position: relative;
  z-index: 0;
  padding-top: 24px;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 34px 0 16px;
}

h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.list-note {
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.45;
}

.soft-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
  transition: transform 140ms ease, background 140ms ease;
}

.soft-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.94);
}

.day-card {
  margin-top: 18px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 58px rgba(90, 66, 42, 0.09);
  overflow: visible;
  backdrop-filter: blur(18px);
}

.day-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 244, 0.64);
  border-radius: 26px 26px 0 0;
}

.day-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 850;
  letter-spacing: -0.02em;
  font-size: 20px;
}

.day-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #f1e4d7;
}

.day-total {
  color: var(--muted);
  font-weight: 750;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
}

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 2px solid rgba(255, 255, 255, 0.58);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 850;
  background: rgba(255, 255, 255, 0.48);
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr {
  transition: background 160ms ease;
  background: var(--task-color, transparent);
}

tbody tr:hover {
  background: var(--task-color-hover, rgba(255,255,255,0.75));
}

/*tbody tr.active-row td:first-child {*/
/*  box-shadow: inset 4px 0 0 rgba(79, 143, 191, 0.58);*/
/*}*/

.status-cell {
  width: 68px;
  text-align: center;
}

.status-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255,255,255,0.58);
  border: 1px solid rgba(61, 49, 35, 0.1);
  transition: transform 140ms ease, background 140ms ease;
}

.status-button:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.92);
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #b8b0a6;
  box-shadow: 0 0 0 6px rgba(184, 176, 166, 0.16);
}

.status-button.status-in_progress .status-indicator {
  background: #4f8fbf;
  box-shadow: 0 0 0 6px rgba(79, 143, 191, 0.18);
  animation: pulse 1.4s ease-in-out infinite;
}

.status-button.status-not_logged .status-indicator {
  background: #b8b0a6;
  box-shadow: 0 0 0 6px rgba(184, 176, 166, 0.16);
}

.status-button.status-logged .status-indicator {
  background: #5f9a72;
  box-shadow: 0 0 0 6px rgba(95, 154, 114, 0.16);
}

.status-button.status-mixed .status-indicator {
  background: #d9953d;
  box-shadow: 0 0 0 6px rgba(217, 149, 61, 0.18);
}

.status-button.status-emergency_stopped .status-indicator {
  background: #b35b5b;
  box-shadow: 0 0 0 6px rgba(179, 91, 91, 0.18);
}

.task-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 108px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.62);
  border: 1px solid rgba(61, 49, 35, 0.09);
  color: inherit;
  font-weight: 900;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 140ms ease, background 140ms ease;
}

.task-badge:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.92);
}

.description {
  max-width: 460px;
  line-height: 1.42;
}

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

.time-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 720;
}

.duration-subline {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.log-time {
  font-weight: 900;
  white-space: nowrap;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tooltip-button {
  position: relative;
}

.tooltip-button::after {
  display: none;
}

.floating-tooltip {
  position: fixed;
  left: 0;
  top: 0;
  max-width: min(320px, calc(100vw - 24px));
  padding: 9px 11px;
  border-radius: 12px;
  background: rgba(45, 42, 38, 0.96);
  color: #fff;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.3;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 9999;
  box-shadow: 0 14px 34px rgba(45, 42, 38, 0.22);
}

.floating-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: var(--text);
  background: rgba(255,255,255,0.62);
  border: 1px solid rgba(61, 49, 35, 0.09);
  font-size: 18px;
  font-weight: 900;
  transition: transform 140ms ease, background 140ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.92);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 20px;
  letter-spacing: -0.03em;
}

/**
 * Toast.
 */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10000;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  width: min(380px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  width: 100%;
  padding: 14px 14px 14px 16px;
  border-radius: 18px;
  background: rgba(45, 42, 38, 0.92);
  color: #fff;
  box-shadow: 0 18px 48px rgba(45, 42, 38, 0.24);
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  pointer-events: auto;
  cursor: pointer;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    background 180ms ease;
  font-weight: 750;
  line-height: 1.35;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast.removing {
  opacity: 0;
  transform: translateY(8px) scale(0.98);
}

.toast.info {
  background: rgba(73, 91, 112, 0.94);
}

.toast.success {
  background: rgba(80, 120, 93, 0.94);
}

.toast.warning {
  background: rgba(159, 105, 45, 0.95);
}

.toast.error {
  background: rgba(142, 78, 78, 0.95);
}

.toast-message {
  min-width: 0;
}

.toast-close {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin: -4px -4px 0 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  font-weight: 800;
  transition: background 140ms ease, transform 140ms ease;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.26);
  transform: scale(1.04);
}

@media (max-width: 860px) {
  .timer-content,
  .list-header,
  .day-head {
    align-items: stretch;
    flex-direction: column;
  }

  .timer-content {
    display: flex;
  }

  .timer-panel {
    min-width: 0;
  }

  .offset-form {
    display: flex;
    align-items: stretch;
  }

  .page {
    width: min(100% - 20px, 1180px);
    padding-top: 20px;
  }
}

/**
 * Day tables.
 */
.day-tables {
  display: grid;
  gap: 18px;
  padding-bottom: 18px;
}

.task-table-block {
  overflow: visible;
}

.task-table-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  padding: 18px 22px 10px;
}

.task-table-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.03em;
}

.task-table-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.summary-table table {
  min-width: 1180px;
}

.summary-time-main {
  font-weight: 900;
  white-space: nowrap;
}

.summary-time-subline {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.summary-muted-value {
  color: var(--muted);
  font-weight: 750;
}

/**
 * Deletion process.
 */
tbody tr.pending-delete {
  opacity: 0.7;
  filter: grayscale(1);
}

tbody tr.pending-delete td {
  position: relative;
}

tbody tr.pending-delete td::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 2px solid rgba(142, 78, 78, 0.58);
  pointer-events: none;
}

tbody tr.pending-delete td:last-child::after {
  display: none;
}

tbody tr.pending-delete:hover {
  background: var(--task-color, transparent);
}

tbody tr.pending-delete .actions {
  opacity: 1;
  filter: none;
}

tbody tr.pending-delete .icon-button {
  background: rgba(255, 255, 255, 0.82);
}

/**
 * History.
 */
.history-section {
  margin-top: 18px;
}

.history-toggle-button {
  position: relative;
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.88);
  color: var(--text);
  box-shadow: 0 14px 42px rgba(90, 66, 42, 0.08);
  backdrop-filter: blur(16px);
  transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.history-toggle-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 48px rgba(90, 66, 42, 0.11);
}

.history-toggle-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 14px;
  background: rgba(143, 111, 81, 0.12);
  color: var(--accent-strong);
  font-size: 18px;
  font-weight: 900;
}

.history-toggle-content {
  display: grid;
  gap: 2px;
  text-align: left;
}

.history-toggle-title {
  font-weight: 900;
  letter-spacing: -0.02em;
}

.history-toggle-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.history-days {
  margin-top: 18px;
}
