/* orderdesk — рабочее место фрилансера.
   Главный акцент интерфейса один: крупная цифра срока слева у каждого заказа.
   Всё остальное спокойное. */

@font-face {
  font-family: "Onest";
  src: url("fonts/onest-cyrillic-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  src: url("fonts/onest-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #eef1ed;
  --surface: #ffffff;
  --ink: #1c2b33;
  --muted: #5f6c74;
  --line: #d9dfda;
  --field: #f6f8f5;
  --overdue: #c42a3c;
  --soon: #a86f00;
  --week: #1c2b33;
  --later: #7d8a91;
  --paid: #2b7a50;
  --focus: #2f6fd6;

  --r-block: 14px;
  --r-control: 10px;
  --tap: 44px;
  --pad: 16px;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121a1f;
    --surface: #1a242a;
    --ink: #e4eaec;
    --muted: #93a1a8;
    --line: #2b383f;
    --field: #141d22;
    --overdue: #ff6b78;
    --soon: #f0b43c;
    --week: #e4eaec;
    --later: #7f8e95;
    --paid: #5fc58e;
    --focus: #7aa7ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

a { color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.wrap { max-width: 680px; margin: 0 auto; padding: 0 var(--pad); }

/* ---------- верхняя панель ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.topbar h1 { font-size: 20px; font-weight: 650; margin: 0; flex: 1; letter-spacing: -0.01em; }
.topbar .back { text-decoration: none; font-size: 15px; color: var(--muted); }

/* ---------- кнопки ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 16px;
  border: 1px solid var(--line); border-radius: var(--r-control);
  background: var(--surface); color: var(--ink);
  font: 550 15px/1 var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-primary:hover { opacity: 0.9; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn-danger { color: var(--overdue); }
.btn-wide { width: 100%; }

/* ---------- нижняя навигация ---------- */

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs .wrap { display: grid; grid-template-columns: repeat(3, 1fr); }
.tabs a {
  display: flex; align-items: center; justify-content: center;
  min-height: 56px; text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 550;
}
.tabs a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 2px 0 var(--ink); }

@media (min-width: 900px) {
  body { padding-bottom: 32px; }
  .tabs { position: sticky; top: 56px; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); background: var(--paper); z-index: 9; }
  .tabs .wrap { display: flex; gap: 4px; }
  .tabs a { min-height: 44px; padding: 0 14px; }
  .tabs a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--ink); }
}

main.wrap { padding-top: 20px; padding-bottom: 24px; }  /* .wrap задает padding, поэтому селектор с классом */

/* ---------- сводка на главной ---------- */

.figures { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border-radius: var(--r-block); overflow: hidden; margin-bottom: 28px; border: 1px solid var(--line); }
.figure { background: var(--surface); padding: 14px 16px; text-decoration: none; display: block; }
.figure .num { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; display: block; }
.figure .cap { font-size: 13px; color: var(--muted); }
.figure .num.owed { color: var(--soon); }

/* ---------- секции и строки заказов ---------- */

.section { margin-bottom: 28px; }
.section h2 { display: flex; align-items: baseline; gap: 8px; font-size: 15px; font-weight: 650; margin: 0 0 8px; }
.section h2 .count { color: var(--muted); font-weight: 500; }
.section.is-overdue h2 { color: var(--overdue); }

.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-block); overflow: hidden; }
.rows li + li { border-top: 1px solid var(--line); }

.row { display: grid; grid-template-columns: 76px 1fr auto; align-items: center; gap: 12px; padding: 12px 16px 12px 0; text-decoration: none; min-height: 64px; }
.row:hover { background: var(--field); }

/* главный акцент — счетчик дней */
.due { align-self: stretch; display: flex; flex-direction: column; justify-content: center; align-items: center; border-left: 4px solid currentColor; line-height: 1; }
.due .n { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; }
.due .l { font-size: 11px; margin-top: 4px; color: var(--muted); font-weight: 500; }
.due.overdue { color: var(--overdue); }
.due.soon { color: var(--soon); }
.due.week { color: var(--week); }
.due.later { color: var(--later); }
.due.later .n { font-size: 20px; }
.due.done { color: var(--paid); }
.due.cancelled { color: var(--later); }

.row .what { min-width: 0; }
.row .title { font-weight: 550; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { font-size: 13px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sum { text-align: right; font-size: 14px; white-space: nowrap; }
.row .sum .owe { color: var(--soon); font-weight: 600; display: block; }
.row .sum .price { color: var(--muted); font-size: 13px; }

.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-block); padding: 28px 20px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 16px; }
.calm { color: var(--paid); font-weight: 550; margin: 0 0 20px; }

/* ---------- фильтры и поиск ---------- */

.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.seg { display: flex; gap: 4px; background: var(--field); border: 1px solid var(--line); border-radius: var(--r-control); padding: 3px; overflow-x: auto; }
.seg a { flex: 1; text-align: center; padding: 9px 10px; border-radius: 8px; text-decoration: none; font-size: 14px; color: var(--muted); white-space: nowrap; }
.seg a[aria-current="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }

/* ---------- формы ---------- */

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; font-weight: 550; }
.field small { color: var(--muted); font-size: 13px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  font: 400 16px/1.3 var(--font); color: var(--ink);
  background: var(--field); border: 1px solid var(--line); border-radius: var(--r-control);
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
input[type="checkbox"] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--ink); }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; }

.error { background: color-mix(in srgb, var(--overdue) 10%, var(--surface)); color: var(--overdue); border: 1px solid color-mix(in srgb, var(--overdue) 35%, transparent); border-radius: var(--r-control); padding: 12px 14px; font-size: 15px; }

/* ---------- карточка заказа ---------- */

.order-head { margin-bottom: 20px; }
.order-head h2 { font-size: 24px; font-weight: 650; margin: 0 0 6px; letter-spacing: -0.015em; line-height: 1.2; }
.order-head .who { color: var(--muted); margin: 0; }
.deadline-line { display: flex; align-items: baseline; gap: 10px; margin-top: 14px; font-weight: 600; }
.deadline-line.overdue { color: var(--overdue); }
.deadline-line.soon { color: var(--soon); }
.deadline-line .date { color: var(--muted); font-weight: 400; }

.block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-block); padding: 16px; margin-bottom: 16px; }
.block h3 { font-size: 15px; font-weight: 650; margin: 0 0 12px; }

.track { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 0; }
.track li { display: flex; align-items: center; gap: 10px; padding: 7px 0; color: var(--muted); font-size: 15px; position: relative; }
.track li::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); flex: none; position: relative; z-index: 1; }
.track li + li::after { content: ""; position: absolute; left: 5px; top: -8px; height: 16px; width: 2px; background: var(--line); }
.track li.past { color: var(--ink); }
.track li.past::before { background: var(--ink); border-color: var(--ink); }
.track li.past + li::after, .track li.now::after { background: var(--ink); }
.track li.now { color: var(--ink); font-weight: 650; }
.track li.now::before { border-color: var(--ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 15%, transparent); }
.stage-actions { display: grid; gap: 10px; }
.stage-jump { display: flex; gap: 8px; }
.stage-jump select { flex: 1; }

.money-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.money-grid div { background: var(--field); border-radius: var(--r-control); padding: 10px 12px; }
.money-grid .k { font-size: 12px; color: var(--muted); display: block; }
.money-grid .v { font-size: 17px; font-weight: 650; }
.money-grid .v.owe { color: var(--soon); }
.money-grid .v.ok { color: var(--paid); }

.plist { list-style: none; margin: 0 0 14px; padding: 0; }
.plist li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.plist li:first-child { border-top: 0; }
.plist .when { color: var(--muted); font-size: 13px; display: block; }
.plist .amt { font-weight: 600; white-space: nowrap; }
.plist .amt.minus { color: var(--overdue); }

.pay-form { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.pay-form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.notes { white-space: pre-wrap; margin: 0; }

details.history summary { cursor: pointer; font-weight: 650; font-size: 15px; min-height: 28px; }
.events { list-style: none; margin: 12px 0 0; padding: 0; font-size: 14px; }
.events li { padding: 6px 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
.events .when { color: var(--muted); white-space: nowrap; }

.order-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }

.badge { display: inline-block; font-size: 13px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--field); border: 1px solid var(--line); }
.badge.done { color: var(--paid); }
.badge.cancelled { color: var(--muted); text-decoration: line-through; }

/* ---------- деньги ---------- */

.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.month-nav h2 { font-size: 20px; margin: 0; font-weight: 650; }
.month-nav a, .month-nav span.btn { min-width: var(--tap); }
.big-figure { font-size: 40px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; margin: 0; }
.tax-note { color: var(--muted); font-size: 14px; margin: 6px 0 0; }

/* ---------- вход ---------- */

.login { min-height: 100vh; display: grid; place-items: center; padding: var(--pad); }
.login form { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.login h1 { font-size: 26px; margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 8px; }

.htmx-request .btn-primary, .btn-primary.htmx-request { opacity: 0.6; pointer-events: none; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

.plist a { text-decoration: none; font-weight: 550; }
.plist a:hover { text-decoration: underline; }
.month-nav .btn { font-size: 22px; }
