:root {
  color-scheme: light;
  --surface: #fff;
  --background: #f7f7f8;
  --tint: #f0f0f2;
  --line: #dedee3;
  --ink: #18191d;
  --muted: #595c65;
  --accent: #bd002d;
  --accent-wash: #fff0f3;
  --good: #236741;
  --shadow: 0 18px 64px #14141c24;
  --radius: 10px;
  --pad: clamp(16px, 4.4vw, 52px);
  --font: "Helvetica Neue", Arial, sans-serif;
  font-family: var(--font);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --surface: #1d1e22;
    --background: #161719;
    --tint: #27282e;
    --line: #383a41;
    --ink: #f7f7f8;
    --muted: #b4b5bf;
    --accent: #ff778c;
    --accent-wash: #331a23;
    --good: #8dd0a4;
    --shadow: 0 18px 64px #0007;
  }
}

:root[data-theme=dark] {
  color-scheme: dark;
  --surface: #1d1e22;
  --background: #161719;
  --tint: #27282e;
  --line: #383a41;
  --ink: #f7f7f8;
  --muted: #b4b5bf;
  --accent: #ff778c;
  --accent-wash: #331a23;
  --good: #8dd0a4;
  --shadow: 0 18px 64px #0007;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--background); color: var(--ink); line-height: 1.5; }
h1, h2, p, ul, dl, dd { margin: 0; }
h1, h2 { line-height: 1.17; }
h1 { font-size: clamp(34px, 5.4vw, 57px); letter-spacing: -.04em; overflow-wrap: anywhere; }
h2 { font-size: 21px; letter-spacing: -.02em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
button, input, select, textarea, dialog { border: 1px solid var(--line); }
button { background: var(--surface); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
svg, img { flex: none; vertical-align: middle; }

.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip:focus { position: fixed; z-index: 20; inset: 8px 8px auto auto; padding: 9px; background: var(--surface); }
.wrap { width: min(100%, 1360px); margin-inline: auto; padding-inline: var(--pad); }
.topbar { background: var(--surface); border-block-end: 1px solid var(--line); }
.top { min-height: 72px; padding-block-start: env(safe-area-inset-top); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.top-actions, .brand { display: flex; align-items: center; gap: 12px; }
.brand { padding: 0; border: 0; background: transparent; font-size: 20px; font-weight: 700; letter-spacing: -.025em; white-space: nowrap; min-height: 44px; }
.brand img { border-radius: 9px; }
.connection { display: inline-flex; align-items: center; gap: 7px; min-height: 24px; font-size: 13px; color: var(--muted); margin-inline-end: 8px; white-space: nowrap; }
.connection i, .badge i, .timer-project i { width: 7px; height: 7px; flex: none; border-radius: 50%; background: currentColor; }
.connection.up i { color: var(--good); }
.connection.down { color: var(--accent); }

.button, .icon-button, .primary, .danger-fill { border-radius: 7px; min-height: 44px; font-weight: 650; }
.button, .primary, .danger-fill { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; text-decoration: none; font-size: 14px; }
.icon-button { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; color: var(--muted); }
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) { background: var(--tint); color: var(--ink); }
.primary, .danger-fill, .button.primary { border-color: transparent; background: #bc002e; color: #fff; }
.primary:hover:not(:disabled), .danger-fill:hover:not(:disabled), .button.primary:hover:not(:disabled) { background: #9d0029; color: #fff; }
.subtle { border-color: transparent; background: transparent; }
.danger, .button.danger:hover { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; unicode-bidi: isolate; white-space: nowrap; }
.dashboard { padding-block: 39px max(48px, env(safe-area-inset-bottom)); }
.dashboard:focus { outline: none; }
.notice { margin-block-end: 16px; border: 1px solid var(--line); border-inline-start: 3px solid var(--good); padding: 9px 14px; background: var(--surface); border-radius: 6px; }
.notice:not(.error) { position: fixed; z-index: 2; inset-inline: auto var(--pad); inset-block-end: max(16px, env(safe-area-inset-bottom)); margin: 0; box-shadow: var(--shadow); }
.notice.error { border-inline-start-color: var(--accent); }
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-title > div:first-child { min-width: 0; }
.title-actions { margin-block-end: 3px; flex: none; }
.current-date, .project-subtitle, .project-description { color: var(--muted); margin-block-start: 7px; }
.project-subtitle { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; }
.project-description { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 68ch; }
.back { padding: 0 0 0 12px; display: flex; align-items: center; gap: 4px; background: transparent; border: 0; color: var(--muted); min-height: 44px; margin-block-end: 4px; }
.back:hover { color: var(--ink); }
.period-row { margin-block: 21px 12px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.periods { display: inline-flex; gap: 2px; border: 1px solid var(--line); background: var(--tint); border-radius: 8px; padding: 3px; }
.periods button { min-height: 44px; padding: 5px 13px; border: 1px solid transparent; background: transparent; border-radius: 5px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.periods button[aria-pressed=true] { background: var(--surface); color: var(--ink); border-color: var(--line); font-weight: 700; }
.detail-actions { display: flex; gap: 5px; flex-wrap: wrap; }

.metrics { display: grid; grid-template-columns: .85fr 1.05fr 1fr 1.1fr; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; background: var(--surface); }
.metric { min-width: 0; padding: 18px clamp(12px, 2.9vw, 30px); }
.metric + .metric { border-inline-start: 1px solid var(--line); }
.metric dt { font-size: 14px; color: var(--muted); font-weight: 600; }
.metric dd { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 8px; line-height: 1; margin-block-start: 11px; }
.metric .num { max-width: 100%; white-space: normal; overflow-wrap: anywhere; font-size: clamp(24px, 3.4vw, 43px); font-weight: 720; letter-spacing: -.05em; }
.metric small { color: var(--muted); font-size: 11px; padding-block-start: 8px; }
.metric.due { background: var(--accent-wash); }
.metric.due .num { color: var(--accent); }
.period-totals { display: flex; align-items: center; justify-content: space-around; gap: 5px; padding: 8px 12px; border: 1px solid var(--line); border-block-start: 0; border-radius: 0 0 var(--radius) var(--radius); background: var(--surface); }
.period-totals > div { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 1px 10px; min-width: 0; }
.period-totals dt { color: var(--muted); font-size: 12px; }
.period-totals dd { font-weight: 700; font-size: 14px; }
.period-totals .num { white-space: normal; overflow-wrap: anywhere; }

.timer-panel { margin-block: 23px 34px; color: #f7f7f8; background: #1b1c21; border: 1px solid #41424b; padding: 19px 23px; border-radius: var(--radius); }
.timer-panel :focus-visible { outline-color: #ff778c; }
.timer-heading { display: flex; align-items: center; gap: 13px; }
.timer-heading h2 { font-size: 19px; }
.timer-heading p { font-size: 13px; color: #c8c9d2; margin-block-start: 3px; }
.timer-mark { display: grid; place-items: center; color: #ff8093; border: 1px solid #53545e; border-radius: 50%; width: 46px; height: 46px; }
.timer-empty { color: #c8c9d2; margin-block-start: 12px; font-size: 14px; }
.timer-list { margin-block-start: 10px; }
.timer-row { display: flex; align-items: center; gap: 12px 22px; border-block-start: 1px solid #41424b; padding-block: 10px; }
.timer-row:last-child { padding-block-end: 0; }
.timer-project { display: inline-flex; align-items: center; gap: 10px; color: #f7f7f8; background: none; border: 0; padding: 0; min-height: 44px; text-align: start; min-width: 0; }
.timer-project span { overflow-wrap: anywhere; }
.timer-project:hover { text-decoration: underline; }
.timer-project i.running { background: #ff637f; }
.timer-project i.paused { background: #b9bbc5; }
.timer-digit { margin-inline-start: auto; font-weight: 720; line-height: 1; font-size: clamp(25px, 4vw, 41px); letter-spacing: -.04em; }
.timer-actions, .row-actions { flex: none; display: flex; align-items: center; gap: 6px; }
.timer-button { min-height: 47px; background: #2b2c34; border-color: #5c5e6b; color: #fff; }
.timer-button:hover:not(:disabled) { background: #41434e; color: #fff; }
.timer-button.start, .timer-button.stop { background: #bc002e; border-color: #f64969; }
.timer-button.start:hover:not(:disabled), .timer-button.stop:hover:not(:disabled) { background: #9d0029; }

.section { margin-block-end: 25px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.section-head { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 17px; border-block-end: 1px solid var(--line); }
.section-head h2 { display: flex; align-items: center; gap: 7px; }
.section-head h2 svg { color: var(--muted); }
.filters { display: flex; gap: 7px; }
input, select, textarea { background: var(--surface); border-radius: 6px; min-height: 44px; width: 100%; padding: 8px 10px; font-size: 16px; }
input, select, textarea { min-inline-size: 0; }
select { padding-inline-end: 20px; }
textarea { resize: vertical; }
.search { position: relative; min-width: 0; }
.search input { padding-inline-start: 35px; }
.search > span:not(.sr-only) { position: absolute; inset-inline-start: 9px; inset-block-start: 10px; color: var(--muted); pointer-events: none; }
.filters select { width: 140px; }
.project-row, .project-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(75px,.27fr) minmax(85px,.3fr) minmax(220px,.46fr); align-items: center; gap: 12px; padding: 9px 17px; }
.project-head { color: var(--muted); font-size: 12px; background: var(--background); min-height: 37px; }
.project-row + .project-row { border-block-start: 1px solid var(--line); }
.project-name { min-width: 0; }
.project-name button { padding: 0; min-height: 32px; max-width: 100%; border: 0; background: transparent; text-align: start; font-weight: 700; overflow-wrap: anywhere; }
.project-name button:hover { color: var(--accent); text-decoration: underline; }
.project-name > div { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge, .project-rate { font-size: 12px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 5px; }
.badge.active i { color: var(--good); }
.badge.archived i { opacity: .6; }
.project-earned .num { white-space: normal; overflow-wrap: anywhere; }
.row-timer { padding-inline: 8px; }
.row-timer.start { color: var(--accent); }
.row-actions { justify-content: flex-end; }
.projects-empty { display: flex; align-items: center; gap: 13px; }
.projects-empty strong { color: var(--ink); }
.empty { padding: 24px 17px; color: var(--muted); font-size: 14px; }
.history-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 0 14px; align-items: start; }
.history-list { padding: 0; list-style: none; }
.history-item { padding: 10px 14px; display: flex; align-items: center; gap: 6px 12px; min-height: 59px; }
.history-item + .history-item { border-block-start: 1px solid var(--line); }
.history-info { display: grid; gap: 1px; flex: 1; min-width: 0; }
.history-info > * { overflow-wrap: anywhere; }
.history-info span, .history-figures span { color: var(--muted); font-size: 13px; }
.history-figures { text-align: end; display: grid; gap: 1px; }
.history-actions { display: flex; gap: 3px; }
.history-actions button { border-color: transparent; }
.paging { border-block-start: 1px solid var(--line); padding: 4px 10px; display: flex; justify-content: flex-end; gap: 4px; }
.project-management { grid-column: 1/-1; display: flex; gap: 7px; flex-wrap: wrap; }

dialog { color: var(--ink); background: var(--surface); width: min(528px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border-radius: 14px; box-shadow: var(--shadow); }
dialog::backdrop { background: #10101699; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 11px 17px; border-block-end: 1px solid var(--line); }
.dialog-head .icon-button { background: transparent; border: 0; }
.form-content, #auth-form { display: grid; gap: 15px; }
.form-content { padding: 18px; }
.form-content label, #auth-form label { display: grid; align-content: start; gap: 5px; font-size: 14px; font-weight: 650; min-width: 0; }
.form-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 9px; }
.dialog-actions { border-block-start: 1px solid var(--line); padding: 10px 17px; display: flex; justify-content: flex-end; gap: 6px; position: sticky; bottom: 0; background: var(--surface); }
.form-help, label small { color: var(--muted); font-size: 13px; font-weight: 400; }
.segment + .segment { margin-block-start: 10px; padding-block-start: 10px; border-block-start: 1px solid var(--line); }
.settings-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.account { overflow-wrap: anywhere; }
.form-error { margin: 0 17px 12px; border: 1px solid var(--line); border-inline-start: 3px solid var(--accent); border-radius: 5px; padding: 8px 10px; color: var(--accent); background: var(--accent-wash); font-size: 14px; }

.auth-body { min-height: 100svh; display: grid; align-items: center; padding: max(20px, env(safe-area-inset-top)) var(--pad) max(20px, env(safe-area-inset-bottom)); }
.auth-layout { width: min(100%, 830px); margin: auto; display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(0, .85fr); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; box-shadow: var(--shadow); }
.auth-card { display: grid; gap: 18px; padding: clamp(20px, 5vw, 48px); }
.auth-card h1 { font-size: clamp(29px, 5vw, 39px); }
.auth-card .form-error { margin: 0; }
.auth-card > .button { justify-self: start; }
.auth-layout:has(.auth-card):not(:has(.auth-aperture)) { width: min(100%, 510px); grid-template-columns: 1fr; }
.auth-aperture { display: grid; place-items: center; min-height: 412px; border-inline-start: 1px solid #3f4049; background: #191a1d url('/icon-512.png') center/contain no-repeat; }
.auth-brand { font-size: 18px; color: var(--muted); }
.password-field { position: relative; }
.password-field input { padding-inline: 12px 49px; }
.password-field button { position: absolute; inset-inline-start: 0; inset-block-start: 0; border: 0; background: transparent; }
.auth-submit { margin-block-start: 6px; min-height: 49px; }
@media (max-width: 900px) {
  .history-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .top { min-height: 62px; }
  .top-actions { gap: 6px; }
  .top-actions .icon-button { background: transparent; border-color: transparent; }
  .brand { font-size: 17px; gap: 7px; }
  .brand img { width: 32px; height: 32px; }
  .connection { font-size: 11px; margin-inline-end: 0; gap: 4px; }
  .dashboard { padding-block-start: 25px; }
  .page-title { align-items: flex-start; }
  .title-actions .button { padding-inline: 8px; }
  .title-actions .button svg { width: 16px; }
  .current-date { font-size: 13px; }
  .period-row { margin-block-start: 17px; }
  .periods { width: 100%; }
  .periods button { flex: 1; padding-inline: 7px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: 12px; }
  .metric + .metric { border-inline-start: 0; }
  .metric:nth-child(even) { border-inline-start: 1px solid var(--line); }
  .metric:nth-child(n+3) { border-block-start: 1px solid var(--line); }
  .metric dd { margin-block-start: 7px; }
  .metric .num { font-size: 29px; }
  .period-totals { padding-inline: 6px; align-items: start; }
  .period-totals > div { flex: 1; display: grid; text-align: center; }
  .timer-panel { margin-block: 17px 23px; padding: 13px; }
  .timer-row { gap: 8px; flex-wrap: wrap; }
  .timer-project { flex-basis: 49%; flex-grow: 1; }
  .timer-row:has(.timer-project) .timer-actions { flex-basis: 100%; justify-content: flex-end; }
  .section-head { align-items: stretch; flex-direction: column; padding: 10px 12px; justify-content: center; }
  .filters { display: grid; grid-template-columns: minmax(0, 1fr) 146px; }
  .filters select { width: 100%; }
  .project-head { display: none; }
  .project-row { grid-template-columns: minmax(0,1fr) auto; gap: 7px 11px; padding: 8px 12px; }
  .project-name { grid-column: 1/-1; }
  .project-name button { min-height: 44px; }
  .project-hours, .project-earned { color: var(--muted); font-size: 13px; }
  .project-hours::before { content: 'זמן '; }
  .project-earned { text-align: end; }
  .row-actions { grid-column: 1/-1; }
  .form-columns { grid-template-columns: minmax(0, 1fr); }
  .auth-layout { grid-template-columns: minmax(0, 1fr); width: min(100%, 440px); }
  .auth-aperture { display: none; }
}
@media (max-width: 360px) {
  .top-actions { gap: 1px; }
  .history-item { flex-wrap: wrap; }
  .history-actions { margin-inline-start: auto; }
  .title-actions .button { font-size: 12px; gap: 4px; }
}
