/*
 * One small design system for the clock, the dashboard and the sign-in page.
 * Right-to-left throughout, so spacing and alignment use logical properties.
 * System fonts only: nothing is fetched from a third party.
 */

:root {
  color-scheme: light;

  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --ink: #0f1729;
  --ink-2: #364152;
  --muted: #667085;
  --line: #e3e6ec;
  --line-2: #cfd4dd;

  --accent: #2158d6;
  --accent-hover: #1a47b3;
  --accent-soft: #e9effd;
  --focus: #6d93f0;

  --in: #137a3f;
  --in-hover: #0f6935;
  --in-soft: #e5f4ea;
  --out: #b42318;
  --out-hover: #9a1d14;
  --out-soft: #fdebe9;
  --warn: #8a4b00;
  --warn-soft: #fff3dc;
  --warn-line: #f3d79b;
  --vac: #1d4ed8;
  --vac-soft: #e8efff;
  --sick: #a1174f;
  --sick-soft: #fde8f1;
  --hol: #0b6b7a;
  --hol-soft: #e3f4f6;
  --neutral-soft: #eef0f4;

  --radius: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 41, 0.04), 0 10px 28px -12px rgba(15, 23, 41, 0.12);

  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Arial Hebrew", Arial,
    sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
dl,
dd,
ul {
  margin: 0;
}

h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

h2 {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
}

h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.3;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ layout */

.shell {
  width: 100%;
  max-width: 460px;
  margin-inline: auto;
  padding: 20px 16px 64px;
}

.shell.wide {
  max-width: 1100px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 8px;
}

.who {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.avatar {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

.avatar svg {
  width: 24px;
  height: 24px;
}

.date-line {
  color: var(--muted);
  font-size: 13px;
}

.card {
  margin-bottom: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-head .title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sub-title {
  margin: 18px 0 8px;
}

.quiet {
  color: var(--muted);
  font-size: 14px;
}

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, transform 0.06s;
}

.btn:hover {
  background: var(--surface-2);
  border-color: #b7bec9;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  color: var(--out);
  border-color: #efc2bd;
}

.btn-danger:hover {
  background: var(--out-soft);
  border-color: #e6a29a;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}

.btn-ghost:hover {
  background: var(--neutral-soft);
  border-color: transparent;
}

.btn-sm {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
}

.btn-lg {
  min-height: 48px;
  font-size: 16px;
}

.btn-icon {
  width: 40px;
  padding: 0;
}

.btn svg {
  width: 18px;
  height: 18px;
}

/* ------------------------------------------------------------------ fields */

.field {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
}

.label {
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

.hint {
  margin-inline-start: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.field-note {
  color: var(--muted);
  font-size: 12px;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="month"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #b7bec9;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
  min-height: 76px;
  resize: vertical;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 14px;
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.span-2 {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 14px;
}

.inline-form .field {
  flex: 1 1 180px;
}

.mode-note {
  padding: 10px 14px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 14px;
}

/* ---------------------------------------------------------------- feedback */

.error,
.notice {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.error,
.notice.bad {
  background: var(--out-soft);
  border: 1px solid #f4c7c2;
  color: var(--out);
}

.notice {
  margin-top: 12px;
  background: var(--neutral-soft);
  border: 1px solid var(--line);
  color: var(--ink-2);
}

.notice.ok {
  background: var(--in-soft);
  border-color: #b9e1c7;
  color: var(--in);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 7px;
  background: var(--neutral-soft);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

.badge-pending,
.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-approved,
.badge-on {
  background: var(--in-soft);
  color: var(--in);
}

.badge-rejected {
  background: var(--out-soft);
  color: var(--out);
}

.badge-cancelled,
.badge-off {
  background: var(--neutral-soft);
  color: var(--muted);
}

.badge-vacation {
  background: var(--vac-soft);
  color: var(--vac);
}

.badge-sick {
  background: var(--sick-soft);
  color: var(--sick);
}

.badge-holiday {
  background: var(--hol-soft);
  color: var(--hol);
}

.badge-open {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-today {
  background: var(--accent);
  color: #fff;
}

.count {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  background: var(--warn);
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  border-radius: 8px;
  color: var(--warn);
  font-size: 13px;
  font-weight: 600;
}

/* ------------------------------------------------------------ lists, panels */

.rows {
  display: grid;
  gap: 8px;
  padding: 0;
  list-style: none;
}

.rows li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.rows li.empty {
  justify-content: center;
  background: transparent;
  border-style: dashed;
  color: var(--muted);
  font-size: 14px;
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.row-sub {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.row-actions .field {
  min-width: 150px;
}

details.panel {
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

details.panel > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  list-style: none;
  cursor: pointer;
}

details.panel > summary::-webkit-details-marker {
  display: none;
}

details.panel > summary::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-inline-start: auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s;
}

details.panel[open] > summary::after {
  transform: rotate(-135deg);
}

details.panel > summary:hover {
  background: var(--surface-2);
}

.panel-text {
  display: grid;
}

.panel-text strong {
  font-size: 15px;
  font-weight: 600;
}

.panel-text small {
  color: var(--muted);
  font-size: 13px;
}

.panel-body {
  padding: 4px 18px 20px;
  border-top: 1px solid var(--line);
}

.panel-body > :first-child {
  margin-top: 16px;
}

/* ------------------------------------------------------------- clock page */

.clock-card {
  padding: 26px 20px 20px;
  text-align: center;
}

.now {
  margin-bottom: 10px;
  font-size: 54px;
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}

.state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 5px 14px;
  background: var(--neutral-soft);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}

.state::before {
  content: "";
  width: 9px;
  height: 9px;
  background: #98a2b3;
  border-radius: 50%;
}

.state[data-state="in"] {
  background: var(--in-soft);
  color: var(--in);
}

.state[data-state="in"]::before {
  background: var(--in);
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(19, 122, 63, 0.45);
  }
  70%,
  100% {
    box-shadow: 0 0 0 8px rgba(19, 122, 63, 0);
  }
}

.punch {
  display: block;
  width: 100%;
  min-height: 88px;
  background: var(--in);
  border: 0;
  border-radius: 20px;
  box-shadow: 0 14px 28px -14px rgba(19, 122, 63, 0.7);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background-color 0.15s, box-shadow 0.15s, transform 0.06s;
}

.punch:hover {
  background: var(--in-hover);
}

.punch:active {
  transform: translateY(1px) scale(0.995);
}

.punch[data-next="out"] {
  background: var(--out);
  box-shadow: 0 14px 28px -14px rgba(180, 35, 24, 0.65);
}

.punch[data-next="out"]:hover {
  background: var(--out-hover);
}

.punch:disabled {
  background: #c9ced8;
  box-shadow: none;
  cursor: progress;
  transform: none;
}

.punch-hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.clock-card .notice,
.clock-card .error {
  margin-top: 14px;
  text-align: start;
}

.totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 22px;
  text-align: start;
}

.tile {
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.tile dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.tile dd {
  margin-top: 2px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.tile small {
  margin-inline-start: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
}

/* --------------------------------------------------------------- dashboard */

.attention {
  background: #fffcf5;
  border-color: var(--warn-line);
}

.attention.is-quiet {
  background: var(--surface);
  border-color: var(--line);
}

.attention.is-quiet .count {
  background: var(--neutral-soft);
  color: var(--muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 14px;
}

.controls .field select {
  min-width: 190px;
}

.controls-end {
  display: flex;
  gap: 10px;
  margin-inline-start: auto;
}

.month-nav {
  display: flex;
  gap: 6px;
}

.month-nav input {
  width: 170px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.stat-value {
  display: block;
  margin-top: 2px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  display: block;
  min-height: 1.4em;
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

th {
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: start;
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:not(.absence):not(.holiday):not(.anomaly):not(.missing):not(.editing):hover td {
  background: #fafbfd;
}

td.num,
.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.date-cell {
  white-space: nowrap;
}

.date-cell .dow {
  display: inline-block;
  min-width: 1.5em;
  margin-inline-end: 6px;
  color: var(--muted);
  font-weight: 500;
}

.date-cell .dmy {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.date-cell .badge {
  margin-inline-start: 8px;
}

/* Each number is its own bidi run. Without the isolation, two adjacent digit
   runs merge into one left-to-right string and the gap lands on the wrong side. */
.hours-cell strong,
.hours-cell .dec,
.date-cell .dow,
.date-cell .dmy {
  unicode-bidi: isolate;
}

.hours-cell strong {
  font-weight: 700;
}

.hours-cell .dec {
  margin-inline-start: 8px;
  color: var(--muted);
  font-size: 12px;
}

.notes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

tr.is-today td:first-child {
  border-inline-start: 3px solid var(--accent);
}

tr.missing td {
  background: var(--surface-2);
  color: var(--muted);
}

tr.absence td {
  background: #f5f8ff;
}

tr.holiday td {
  background: #f1f9fa;
}

tr.anomaly td {
  background: #fff6e5;
}

tr.editing td {
  background: var(--accent-soft);
}

tr.editing input[type="time"] {
  min-height: 36px;
  width: 7.5em;
}

tr.editing input[type="text"] {
  min-height: 36px;
}

td .btn + .btn {
  margin-inline-start: 6px;
}

td.actions {
  text-align: end;
  white-space: nowrap;
}

.card details.panel {
  margin: 14px 0 0;
  box-shadow: none;
}

.empty-cell {
  padding: 28px 14px;
  color: var(--muted);
  text-align: center;
}

.row-actions input[type="text"] {
  width: 170px;
  min-height: 34px;
  padding: 5px 10px;
}

.table-wrap.is-loading {
  opacity: 0.55;
  transition: opacity 0.15s;
}

.credentials-result {
  margin-top: 14px;
  padding: 16px;
  background: var(--in-soft);
  border: 1px solid #b9e1c7;
  border-radius: var(--radius-md);
}

.credentials-result h2 {
  margin-bottom: 4px;
}

.credentials-result input[readonly] {
  margin: 10px 0;
  direction: ltr;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-align: center;
}

/* ---------------------------------------------------------- sign-in, blocked */

.auth {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  margin: 0;
  padding: 28px 24px 24px;
}

.auth-brand {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-bottom: 22px;
  text-align: center;
}

.auth-brand .avatar {
  width: 52px;
  height: 52px;
  border-radius: 16px;
}

.login {
  display: grid;
  gap: 16px;
}

.auth-card > .error,
.auth-card > .quiet {
  margin-top: 14px;
}

.auth-card .quiet {
  text-align: center;
}

/* -------------------------------------------------------------- small screens */

@media (max-width: 640px) {
  .shell {
    padding: 14px 12px 48px;
  }

  .card {
    padding: 16px;
    border-radius: 14px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .controls > * {
    flex: 1 1 100%;
  }

  .controls-end {
    margin-inline-start: 0;
  }

  .controls-end > * {
    flex: 1;
  }

  .month-nav input {
    flex: 1;
    width: auto;
  }

  .rows li {
    flex-wrap: wrap;
  }

  .now {
    font-size: 46px;
  }

  th,
  td {
    padding: 9px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------------ quotes */

.badge-draft    { background: var(--neutral-soft); color: var(--muted); }
.badge-sent     { background: var(--accent-soft);  color: var(--accent); }
.badge-accepted { background: var(--in-soft);      color: var(--in); }
.badge-rejected { background: var(--out-soft);     color: var(--out); }
.badge.ok   { background: var(--in-soft);   color: var(--in); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad  { background: var(--out-soft);  color: var(--out); }
.strike { text-decoration: line-through; }

/* --- editor: a fixed bar, then two panes that scroll independently ------ */

body.editor { overflow: hidden; }

.editor-shell { display: flex; flex-direction: column; height: 100vh; }

.editor-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex: 0 0 auto;
}
.editor-bar .back {
  font-size: 20px;
  line-height: 1;
  text-decoration: none;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.editor-bar .back:hover { background: var(--bg); color: var(--ink); }
.bar-name {
  flex: 1 1 260px;
  min-width: 140px;
  max-width: 420px;
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  background: transparent;
  color: inherit;
}
.bar-name:hover  { border-color: var(--line); }
.bar-name:focus  { border-color: var(--accent); background: var(--bg); outline: none; }
.bar-status {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  background: var(--bg);
  color: inherit;
}
.bar-end { margin-inline-start: auto; display: flex; gap: 6px; align-items: center; }

.save-state { font-size: 12px; color: var(--muted); min-width: 56px; }
.save-state.is-saved { color: var(--in); }
.save-state.is-dirty { color: var(--warn); }

.editor-split {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(420px, 1.15fr);
  min-height: 0;
}
.editor-pane  { overflow-y: auto; padding: 14px 16px 60px; border-inline-end: 1px solid var(--line); }
.preview-pane { overflow: hidden; display: flex; flex-direction: column; background: var(--bg); }

@media (max-width: 1000px) {
  body.editor { overflow: auto; }
  .editor-shell { height: auto; }
  .editor-split { grid-template-columns: 1fr; }
  .editor-pane { border-inline-end: 0; }
}

/* --- collapsible sections ----------------------------------------------- */

.pane-section {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 10px;
}
.pane-section > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.pane-section > summary::-webkit-details-marker { display: none; }
.pane-section > summary:hover { background: var(--bg); border-radius: var(--radius-sm); }
.pane-title { font-weight: 700; }
.pane-chevron { margin-inline-start: auto; color: var(--muted); transition: transform .15s; }
.pane-section[open] > summary .pane-chevron { transform: rotate(180deg); }
.pane-body { padding: 0 14px 14px; display: grid; gap: 10px; }

/* --- pickers: the catalogue and the clause library ---------------------- */

.picker {
  max-height: 210px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 6px;
}
.pick-group + .pick-group { margin-top: 8px; }
.pick-group-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 4px 6px 2px;
}
.pick-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: start;
  cursor: pointer;
}
.pick-item:hover { background: var(--accent-soft); }
.pick-plus { color: var(--accent); font-weight: 700; }
.pick-name { flex: 1; }
.pick-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* --- chosen rows: services and clauses share one card shape ------------- */

.chosen { display: grid; gap: 8px; }
.row-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  background: var(--bg);
}
.row-card-head { display: flex; gap: 6px; align-items: center; }
.row-card-head input { flex: 1; }
.row-card input, .row-card textarea, .row-card select {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  background: var(--surface);
  color: inherit;
}
.row-card textarea { width: 100%; margin-top: 6px; resize: vertical; }
.row-card-foot {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px;
  font-size: 12px; color: var(--muted);
}
.row-card-foot label { display: flex; align-items: center; gap: 5px; }
.row-card-foot input { width: 86px; }
.row-card-hint { margin-top: 5px; font-size: 11px; color: var(--muted); }
.clause-n { font-weight: 700; color: var(--muted); }
.btn-icon.danger { color: var(--out); }

/* --- margin meter -------------------------------------------------------- */

.meter { display: grid; }
.meter-row { display: grid; gap: 2px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.meter-row:last-child { border-bottom: 0; }
.meter-label { font-weight: 600; }
.meter-money { display: flex; gap: 8px; align-items: baseline; justify-content: flex-end; }

/* --- the live preview ---------------------------------------------------- */

.preview-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 600; color: var(--muted);
  flex: 0 0 auto;
}
.preview-scroll { flex: 1 1 auto; overflow: auto; padding: 12px; }
/* The sizer carries the scaled dimensions; a transformed iframe keeps its
   full size in layout, so without it the pane has nothing to scroll. */
.preview-sizer { margin-inline-start: auto; }
#preview {
  width: 794px;            /* 210mm at 96dpi, then scaled to the pane */
  border: 1px solid var(--line);
  background: #fff;
  transform-origin: top right;
  display: block;
}

/* --- quotes: list filter -------------------------------------------------- */

/* A filtered-out row has to be gone, not merely invisible: a table row keeps
   its display role under [hidden] in some engines and leaves a gap behind. */
#quote-rows tr[hidden] { display: none; }

.filter-input {
  min-width: 260px;
  padding: 0 12px;
  min-height: 38px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
}

.filter-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* --- quotes: dialogs ----------------------------------------------------- */

.sheet-dialog {
  width: min(760px, calc(100vw - 32px));
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.sheet-dialog.narrow { width: min(460px, calc(100vw - 32px)); }
.sheet-dialog::backdrop { background: rgba(15, 23, 41, 0.45); }
.sheet-dialog h2 { margin: 0 0 4px; font-size: 20px; }
.sheet-dialog > .quiet { margin: 0 0 18px; line-height: 1.55; }

.dialog-close { display: flex; justify-content: flex-end; margin-bottom: -10px; }

.dialog-close button {
  padding: 4px 8px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}

.dialog-close button:hover { background: var(--neutral-soft); }

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
}

/* --- quotes: template picker --------------------------------------------- */

.tpl-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  max-height: min(60vh, 520px);
  overflow-y: auto;
}

/* The card is what positions the delete button. It sits over the picker
   rather than inside it, because a button does not nest inside a button. */
.tpl-card { position: relative; display: flex; }

.tpl-pick {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-md);
  color: var(--ink);
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.tpl-pick:hover { background: var(--accent-soft); border-color: var(--accent); }

.tpl-pick:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tpl-blank { border-style: dashed; background: var(--surface); }

.tpl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tpl-name { font-weight: 700; }
.tpl-desc { color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.tpl-facts { color: var(--muted); font-size: 12px; }

.chip {
  flex: none;
  padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.tpl-remove {
  position: absolute;
  top: 6px;
  inset-inline-start: 6px;
}

.tpl-card:not(:hover) .tpl-remove:not(:focus-visible) { opacity: 0; }

/* --- quotes: readiness --------------------------------------------------- */

/* Not an error: the document saves and prints either way. This is the list
   someone would read back to you before you press send. */
.readiness {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  margin: 0 16px 10px;
  padding: 10px 14px;
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-sm);
  color: var(--warn);
  font-size: 13px;
}

.readiness-label { font-weight: 700; }

.readiness ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Not display:flex on the item. A flex container promotes every inline child
   to a flex item and wedges the gap between them, which scatters a sentence
   across the row — the same trap the document's notes list fell into. */
.readiness li { position: relative; padding-inline-start: 12px; }

.readiness li::before {
  content: '\2022';
  position: absolute;
  inset-inline-start: 0;
}

/* --- quotes: the list on a narrow screen ---------------------------------- */

/* Five columns do not fit a phone. Below this width each row becomes a block
   of its own: the heading row goes away, the cells stack, and the actions sit
   on one line under them. Left as a table it scrolls sideways and the title
   wraps a character at a time. */
@media (max-width: 720px) {
  #quote-rows tr,
  #quote-rows td {
    display: block;
    width: auto;
  }

  .shell [data-view] table thead,
  main[data-view='list'] table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  #quote-rows tr {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
  }

  #quote-rows tr:last-child { border-bottom: 0; }

  #quote-rows td {
    padding: 2px 0;
    border: 0;
  }

  /* The amount and the date read as one line rather than as two rows. */
  #quote-rows td:nth-child(3),
  #quote-rows td:nth-child(4) {
    display: inline-block;
    margin-inline-end: 12px;
  }

  #quote-rows .row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
  }

  #quote-rows .row-actions .btn { flex: 1 1 auto; }

  .filter-input { width: 100%; min-width: 0; }

  .readiness { margin-inline: 12px; }
}

/* --- quotes: payment methods ---------------------------------------------- */

/* The editor's picker. Each option is a label wrapping its checkbox, so the
   whole row is the hit target, not the 16px box. */
.pm-pick { display: grid; gap: 8px; margin-bottom: 12px; }

.pm-opt {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.pm-opt:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.pm-opt input { margin-top: 3px; accent-color: var(--accent); }

/* Block children, not a flex row: the name, the summary and the note are
   each a line of Hebrew, and a flex container would split their inline
   children apart. */
.pm-opt-text > span { display: block; }
.pm-opt-name { font-weight: 700; }
.pm-opt-sum { color: var(--ink-2); font-size: 13px; }
.pm-opt-note { color: var(--warn); font-size: 12px; margin-top: 2px; }

.link-btn {
  padding: 0;
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.pm-manage { margin: 6px 0 0; font-size: 13px; }

/* The settings list. */
.pm-list { display: grid; gap: 10px; }

.pm-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.pm-row.is-off { opacity: 0.6; background: var(--surface-2); }
.pm-row-main > div + div { margin-top: 3px; }
.pm-row-name { font-weight: 700; }
.pm-row-name .chip { margin-inline-start: 6px; vertical-align: 1px; }
.pm-row-sum { color: var(--ink-2); font-size: 14px; }
.pm-row-meta { color: var(--muted); font-size: 12px; }
.pm-row-actions { display: flex; gap: 6px; }

/* A group of fields for one kind spans the dialog's grid and lays its own
   fields out on the same two columns. */
.pm-fields { grid-column: 1 / -1; }

/* --- quotes: sending to the client ---------------------------------------- */

.btn-send { color: var(--accent); border-color: var(--accent); }
.btn-send:hover { background: var(--accent-soft); border-color: var(--accent); }

.share-row { display: flex; gap: 8px; }

.share-row input {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.share-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* WhatsApp's own green, because that is what people look for. */
.btn-whatsapp { background: #25d366; border-color: #25d366; color: #fff; }
.btn-whatsapp:hover { background: #1ebe5a; border-color: #1ebe5a; }

.share-stats { margin: 14px 0 0; color: var(--ink-2); font-size: 13px; }

.share-danger {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* The list's note on whether a document went out and was opened. */
.share-note { color: var(--muted); }
.share-note.is-seen { color: var(--in); font-weight: 600; }

/* --- quotes: acceptance in the editor -------------------------------------- */

.accepted-strip {
  margin: 0 16px 10px;
  padding: 10px 14px;
  background: var(--in-soft);
  border: 1px solid #b7dfc4;
  border-radius: var(--radius-sm);
  color: var(--in);
  font-size: 13px;
}

.accepted-strip.is-stale {
  background: var(--warn-soft);
  border-color: var(--warn-line);
  color: var(--warn);
}

.accepted-strip a { color: inherit; font-weight: 700; }
