/* ============ Дуб и Ясень · CRM ============ */
/* Warm workshop palette: light beige bg, walnut ink, amber accent. */

:root {
  --bg: #f7f2ea;
  --card: #ffffff;
  --card-border: #e8ddcd;
  --shadow: 0 1px 2px rgba(74, 49, 26, 0.06), 0 4px 12px rgba(74, 49, 26, 0.08);
  --ink: #3a2f28;
  --ink-soft: #6b5a4c;
  --ink-mute: #8a7663;
  --accent: #7a4a24;         /* walnut brown */
  --accent-hover: #63391a;
  --accent-soft: #f3e6d8;
  --accent-ink: #ffffff;
  --ok: #4a7c3f;
  --ok-soft: #e7f0e2;
  --warn: #b45309;           /* deep amber, AA on white */
  --warn-soft: #fbf0e0;
  --err: #b3261e;
  --err-soft: #fbe9e7;
  --focus: #a05a1f;
  --radius: 10px;
  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-text: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

/* ============ Header ============ */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  min-height: 44px;
}
.brand-mark {
  width: 44px; height: 44px;
  flex: 0 0 44px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  color: var(--ink);
}
.brand-sub {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.site-nav { display: flex; align-items: center; gap: 4px; }
.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 15px;
}
.nav-link:hover { background: var(--accent-soft); color: var(--accent-hover); }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent-hover); }
.logout-form { display: inline; }
.btn-link {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  color: var(--ink-soft);
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
}
.btn-link:hover { background: var(--accent-soft); color: var(--accent-hover); }

/* ============ Main ============ */
.site-main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
.site-footer {
  border-top: 1px solid var(--card-border);
  padding: 16px 20px;
  text-align: center;
  color: var(--ink-mute);
  font-size: 13px;
  background: var(--card);
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  text-decoration: none;
}
.btn:hover { background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 6px 14px; font-size: 14px; }
.btn-adv { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-adv:hover { background: var(--accent-hover); }

/* ============ Panel (dashboard) ============ */
.panel {
  background: transparent;
}
.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.panel-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.panel-sub {
  margin: 4px 0 0;
  color: var(--ink-mute);
  font-size: 14px;
}

/* ============ Search ============ */
.searchbar {
  position: relative;
  margin-bottom: 20px;
}
.search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--ink-mute);
  pointer-events: none;
}
.searchbar input[type="search"] {
  width: 100%;
  min-height: 48px;
  padding: 12px 84px 12px 44px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--card);
  font: inherit;
  color: var(--ink);
}
.searchbar input[type="search"]:focus {
  border-color: var(--focus);
}
.search-clear {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  min-height: 36px;
}

/* ============ Request list ============ */
.req-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.req-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 20px;
  align-items: start;
}
.req-name {
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
}
.req-row1 { display: flex; align-items: center; gap: 10px; }
.req-text {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 15px;
  word-break: break-word;
}
.req-meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  font-size: 14px;
}
.req-phone {
  color: var(--accent-hover);
  font-weight: 600;
  text-decoration: none;
}
.req-phone:hover { text-decoration: underline; }
.req-source {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-radius: 6px;
  padding: 2px 10px;
  font-size: 13px;
  font-weight: 600;
}
.req-date { color: var(--ink-mute); font-size: 13px; }
.req-comment {
  margin: 10px 0 0;
  padding: 8px 12px;
  background: var(--warn-soft);
  border-left: 3px solid var(--warn);
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 14px;
}
.req-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  min-width: 150px;
}
.status-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* Status chips: wood inlays per status */
.status-chip {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.status-new      { background: #eef3e4; color: #4a6b2f; border: 1px solid #cfdcae; } /* light birch */
.status-measure  { background: #f7ecd9; color: #8a5a1f; border: 1px solid #e3cba1; } /* honey oak */
.status-work     { background: #f6e0d2; color: #9c4a1e; border: 1px solid #e0b494; } /* mid oak */
.status-done     { background: #5c3d2e; color: #fdf6ee; border: 1px solid #4a2f22; } /* dark walnut */
.status-rejected { background: #f0e5e2; color: #8a4a3d; border: 1px solid #d9bcb4; } /* faded */

.req-empty {
  text-align: center;
  color: var(--ink-mute);
  padding: 48px 20px;
  background: var(--card);
  border: 1px dashed var(--card-border);
  border-radius: var(--radius);
}
.req-empty svg { color: #c9b79c; margin-bottom: 8px; }

/* Highlight matched search text */
mark.hl {
  background: #ffe08a;
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

/* ============ Dialog ============ */
.dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  background: var(--card);
  box-shadow: 0 20px 60px rgba(40, 25, 10, 0.35);
  max-width: 520px;
  width: calc(100% - 32px);
}
.dialog::backdrop { background: rgba(40, 25, 10, 0.45); }
.dialog form { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.dialog-title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

/* ============ Forms ============ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}
.field input,
.field textarea,
.field select {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: var(--ink);
}
.field textarea { min-height: 72px; resize: vertical; }
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--focus);
}
.req-mark { color: var(--err); }
.form-error {
  color: var(--err);
  background: var(--err-soft);
  border: 1px solid #f0c4bf;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
}
.form-error-hidden { display: none; }

/* ============ Login ============ */
.login-wrap {
  display: grid;
  place-items: center;
  padding: 32px 0;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.login-mark {
  width: 64px; height: 64px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 1px;
}
.login-title {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
}
.login-sub {
  margin: 0;
  color: var(--ink-mute);
  font-size: 14px;
}
.login-form { width: 100%; display: flex; flex-direction: column; gap: 16px; }
#login-submit {
  transition: background 0.15s, transform 0.05s;
}
#login-submit.is-loading { opacity: 0.7; pointer-events: none; }

/* ============ Calculator ============ */
.calc { background: transparent; }
.calc-head { margin-bottom: 22px; }
.calc-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 24px;
  align-items: start;
}
.calc-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.calc-group {
  border: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.calc-group legend {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 0;
  margin-bottom: 4px;
}
.opt-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.opt {
  flex: 1 1 100px;
  position: relative;
  cursor: pointer;
}
.opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.opt-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: #fff;
  font-weight: 600;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.opt input:focus-visible + .opt-label {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.opt input:checked + .opt-label {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-hover);
}
.opt-rate {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-mute);
}
.opt input:checked + .opt-label .opt-rate { color: var(--accent-hover); }
.calc-dims {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.calc-result {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  position: sticky;
  top: 88px;
}
.calc-empty {
  color: var(--ink-mute);
  margin: 0;
  padding: 20px 0;
  text-align: center;
}
.calc-breakdown {
  margin: 0 0 16px;
  border-bottom: 1px dashed var(--card-border);
  padding-bottom: 16px;
}
.calc-breakdown dl {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.calc-breakdown div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.calc-breakdown dt { color: var(--ink-soft); font-size: 14px; }
.calc-breakdown dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.calc-total {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.calc-total-label {
  font-size: 14px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.calc-total-value {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  color: var(--accent-hover);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.calc-note {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--ink-mute);
}
.hidden { display: none !important; }

/* ============ Responsive ============ */
@media (max-width: 760px) {
  .site-main { padding: 16px 14px 40px; }
  .panel-title { font-size: 24px; }
  .calc-grid { grid-template-columns: 1fr; }
  .calc-result { position: static; }
  .req-card {
    grid-template-columns: 1fr;
    padding: 14px 16px;
  }
  .req-actions {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    border-top: 1px dashed var(--card-border);
    padding-top: 12px;
    margin-top: 4px;
  }
  .status-btns { justify-content: flex-start; }
  .header-inner { padding: 8px 14px; }
  .brand-name { font-size: 17px; }
  .brand-sub { font-size: 10px; }
  .nav-link { padding: 8px 10px; font-size: 14px; }
  .calc-dims { grid-template-columns: 1fr 1fr; }
  .opt-row { flex-direction: column; }
  .opt { flex: 1 1 auto; }
  /* header: brand + nav exceed 360px — let the nav wrap to its own line */
  .header-inner { flex-wrap: wrap; row-gap: 0; }
  .site-nav { flex-wrap: wrap; }
}
