@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap");

:root {
  --rs-ink: #18181b;        /* zinc-900 — primary text / dark surfaces */
  --rs-ink-soft: #27272a;   /* zinc-800 — hover on dark */
  --rs-muted: #52525b;      /* zinc-600 — secondary text */
  --rs-faint: #a1a1aa;      /* zinc-400 — tertiary text */
  --rs-line: #e4e4e7;       /* zinc-200 — borders */
  --rs-surface: #ffffff;
  --rs-bg: #f4f4f5;         /* zinc-100 — page background */
  --rs-accent: #dc2626;     /* red-600 — brand accent */
  --rs-accent-dark: #b91c1c;/* red-700 */
  --rs-radius: 6px;
  --logo-teal: #00f9c4;     /* logo mark */
  --logo-navy: #01A5C8;     /* logo wordmark */
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--rs-ink);
  background: var(--rs-bg);
}

h1, h2 { font-weight: 700; letter-spacing: -0.01em; }

/* ── Login / logout-success ── */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 1.5rem;
  padding: 1.5rem;
}

.login-container .logo {
  width: 260px;
  max-width: 80vw;
  height: auto;
}

.login-container h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--rs-muted);
}

/* ── Layout ── */
header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1.5rem;
  background: var(--rs-surface);
  border-bottom: 1px solid var(--rs-line);
}

.brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.brand .logo {
  height: 30px;
  width: auto;
  display: block;
}

header h1 {
  margin: 0;
  padding-left: 1.25rem;
  border-left: 1px solid var(--rs-line);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--rs-muted);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-left: auto;
}

.header-nav a {
  color: var(--rs-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.header-nav a:hover {
  color: var(--rs-accent);
}

.header-nav button {
  border-color: transparent;
  background: transparent;
  color: var(--rs-muted);
}

.header-nav button:hover {
  background: var(--rs-bg);
  border-color: transparent;
  color: var(--rs-ink);
}

main {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 1.5rem 3rem;
}

/* ── Messages ── */
.success {
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--rs-radius);
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}

/* ── Project list ── */
.project-search {
  margin-bottom: 1rem;
}

.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.project-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--rs-surface);
  border: 1px solid var(--rs-line);
  border-radius: var(--rs-radius);
  padding: 0.75rem 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.project-card:hover {
  border-color: var(--rs-faint);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.project-card strong {
  flex: 1;
  font-weight: 600;
}

.project-card form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Table ── */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--rs-surface);
  border: 1px solid var(--rs-line);
  border-radius: var(--rs-radius);
  overflow: hidden;
}

th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: var(--rs-bg);
  border-bottom: 1px solid var(--rs-line);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--rs-muted);
}

td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--rs-line);
  vertical-align: middle;
}

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

.text-input {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--rs-line);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  color: var(--rs-ink);
}

.text-input:focus {
  outline: none;
  border-color: var(--rs-accent);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
}

.bexio-text {
  margin-top: 0.2rem;
  padding: 0 0.5rem;
  font-size: 12px;
  color: var(--rs-faint);
}

.actions {
  white-space: nowrap;
}

.print {
  text-align: center;
}

.deleted-row {
  background: var(--rs-bg);
}

.deleted-row .text-input {
  color: var(--rs-faint);
  background: var(--rs-bg);
  text-decoration: line-through;
}

.deleted-row td {
  color: var(--rs-faint);
}

/* ── Toggle switch ── */
.toggle {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle .slider {
  position: absolute;
  inset: 0;
  background: #d4d4d8;
  border-radius: 10px;
  transition: background 0.15s;
}

.toggle .slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}

.toggle input:checked + .slider {
  background: var(--rs-accent);
}

.toggle input:checked + .slider::before {
  transform: translateX(14px);
}

/* ── Buttons ── */
button, .btn, .btn-primary {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--rs-line);
  border-radius: 4px;
  background: var(--rs-surface);
  color: var(--rs-ink);
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

button:hover, .btn:hover, .btn-primary:hover {
  background: var(--rs-bg);
  border-color: var(--rs-faint);
}

.btn-primary {
  background: var(--rs-ink);
  border-color: var(--rs-ink);
  color: #fff;
}

.btn-primary:hover {
  background: var(--rs-ink-soft);
  border-color: var(--rs-ink-soft);
  color: #fff;
}

.btn-danger {
  border-color: var(--rs-accent);
  color: var(--rs-accent);
}

.btn-danger:hover {
  background: #fef2f2;
  border-color: var(--rs-accent-dark);
  color: var(--rs-accent-dark);
}

input[type="date"] {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--rs-line);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  color: var(--rs-ink);
}

/* --- Chronos additions --- */
.btn-sm { padding: .25rem .5rem; font-size: .8rem; }
.unmapped-row { opacity: .7; }
.result-banner { margin: 1rem 0; padding: .75rem 1rem; border-radius: 6px;
  background: #ecfdf5; border: 1px solid #a7f3d0; }
.result-banner ul { margin: .5rem 0 0; padding-left: 1.25rem; }
textarea.text-input { width: 100%; resize: none; border-color: transparent; background: transparent; }
textarea.text-input:hover { border-color: var(--rs-line); background: var(--rs-bg); }
textarea.text-input:focus { border-color: var(--rs-faint); background: var(--rs-surface); box-shadow: none; }
/* Submitted rows: no editing affordance on the frozen description */
textarea.text-input[readonly] { cursor: default; }
textarea.text-input[readonly]:hover,
textarea.text-input[readonly]:focus { border-color: transparent; background: transparent; }

.btn-generate-all.htmx-request {
  color: var(--rs-ink);
  background-color: #fff;
  background-image: radial-gradient(circle at 50% 50%, var(--logo-navy) 0%, var(--logo-teal) 40%, #fff 75%);
  background-size: 220% 220%;
  background-repeat: no-repeat;
  animation: point-gradient-move 3s linear infinite;
}

@keyframes point-gradient-move {
  0%     { background-position: 83.0% 50.0%; }
  4.167% { background-position: 81.9% 58.2%; }
  8.333% { background-position: 78.6% 64.3%; }
  12.5%  { background-position: 73.3% 66.5%; }
  16.67% { background-position: 66.5% 64.3%; }
  20.83% { background-position: 58.5% 58.2%; }
  25%    { background-position: 50.0% 50.0%; }
  29.17% { background-position: 41.5% 41.8%; }
  33.33% { background-position: 33.5% 35.7%; }
  37.5%  { background-position: 26.7% 33.5%; }
  41.67% { background-position: 21.4% 35.7%; }
  45.83% { background-position: 18.1% 41.7%; }
  50%    { background-position: 17.0% 50.0%; }
  54.17% { background-position: 18.1% 58.2%; }
  58.33% { background-position: 21.4% 64.3%; }
  62.5%  { background-position: 26.7% 66.5%; }
  66.67% { background-position: 33.5% 64.3%; }
  70.83% { background-position: 41.5% 58.2%; }
  75%    { background-position: 50.0% 50.0%; }
  79.17% { background-position: 58.5% 41.8%; }
  83.33% { background-position: 66.5% 35.7%; }
  87.5%  { background-position: 73.3% 33.5%; }
  91.67% { background-position: 78.6% 35.7%; }
  95.83% { background-position: 81.9% 41.7%; }
  100%   { background-position: 83.0% 50.0%; }
}

/* ── Day header ── */
.day-header {
  display: flex;
  align-items: flex-end;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.day-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.day-subtitle {
  margin-top: 2px;
  font-size: 13px;
  color: var(--rs-muted);
}

.day-subtitle strong { color: var(--rs-ink); font-weight: 600; }

.date-nav {
  margin-left: auto;
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.date-nav .btn {
  display: inline-flex;
  align-items: center;
  height: 36px;
  border-radius: 8px;
  box-sizing: border-box;
}

.date-pager {
  display: flex;
  align-items: center;
  border: 1px solid #d4d4d8;
  border-radius: 8px;
  background: var(--rs-surface);
  overflow: hidden;
  height: 36px;
}

.date-pager input[type="date"] {
  border: none;
  border-left: 1px solid var(--rs-line);
  border-right: 1px solid var(--rs-line);
  border-radius: 0;
  height: 34px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--rs-muted);
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}

.btn-icon:hover { background: var(--rs-bg); color: var(--rs-ink); }

/* ── Entries table ── */
.entries-card {
  background: var(--rs-surface);
  border: 1px solid var(--rs-line);
  border-radius: 10px;
  overflow: hidden;
}

/* border-collapse: separate avoids a Safari hairline-seam bug where the shared border of a
   column with a non-integer computed width (the flexible Beschreibung column) rounds to a
   different subpixel position than its neighbors under border-collapse: collapse. */
.entries-table { border: none; border-radius: 0; table-layout: fixed; border-collapse: separate; border-spacing: 0; }

.entries-table th {
  background: var(--rs-surface);
  font-size: 0.7rem;
  color: var(--rs-faint);
  padding: 10px 16px;
}

.entries-table td { vertical-align: top; padding: 14px 16px; }

.entries-table th:nth-child(1), .entries-table td:nth-child(1) { width: 130px; }
.entries-table th:nth-child(2), .entries-table td:nth-child(2) { width: 220px; }
.entries-table th:nth-child(4), .entries-table td:nth-child(4) { width: 130px; }

.col-description {
  display: flex;
  align-items: center;
  gap: 10px;
}

.col-description button { margin-left: auto; text-transform: none; letter-spacing: 0; }

/* Aligns the header label with the textarea's text, which starts one .text-input
   left-padding further in than the td's own padding. */
.col-description span { margin-left: 0.5rem; }

.cell-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell-primary { font-weight: 600; color: var(--rs-ink); }
.cell-secondary { font-size: 12px; color: var(--rs-faint); margin-top: 2px; }

/* Project/customer never wrap onto a second line — a long name must not inflate the row
   height beyond what the description column actually needs, so it truncates instead. */
.cell-project .cell-primary,
.cell-project .cell-secondary {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.description-cell { display: flex; align-items: flex-start; gap: 6px; }
.description-cell textarea { flex: 1; }

.btn-icon-ai {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  margin-top: 2px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--rs-faint);
  font-size: 13px;
  cursor: pointer;
}

.btn-icon-ai:hover { background: var(--rs-bg); color: var(--rs-ink); }

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.status-open { background: var(--rs-bg); color: var(--rs-muted); }
.status-submitted { background: #ecfdf5; color: #047857; }
.status-unmapped { background: #fef3c7; color: #92400e; }

.entries-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 14px 20px;
  background: var(--rs-surface);
  border-top: 1px solid var(--rs-line);
  font-size: 13px;
  color: var(--rs-muted);
}

.entries-footer strong { color: var(--rs-ink); font-weight: 600; }

.entries-footer button { margin-left: auto; }

/* Zusammenzug pro Kunde: zweite Zeile der Fusszeile, direkt unter dem Tagestotal. */
.footer-totals { min-width: 0; }

.customer-totals {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
}

.customer-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.customer-total-name { font-weight: 600; color: var(--rs-ink); }

.customer-total-unmapped { font-size: 12px; color: #92400e; }

/* Hint when the Timely note write-back fails; wraps onto its own line below the textarea. */
.description-cell { flex-wrap: wrap; }
.note-status { flex-basis: 100%; font-size: .75rem; }
.note-status-error { color: #92400e; }
