:root {
  --ink: #1f1a16;
  --muted: #6f655c;
  --paper: #f3efe6;
  --surface: #fffdf8;
  --line: #e0d6c8;
  --teal: #1c6b5a;
  --teal-dark: #134c40;
  --gold: #c4a35a;
  --danger: #b42318;
  --warn: #f5e1a4;
  --overdue: #f8d7d3;
  --upcoming: #dceee8;
  --sidebar: #14261f;
  --sidebar-text: #efe7d8;
  --header-h: 72px;
  --sidebar-w: 268px;
  --radius: 14px;
  --shadow: 0 12px 30px rgba(31, 26, 22, 0.08);
  --font: "Vazirmatn", Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
}

body.app-body {
  margin: 0;
  display: flex;
}

a { color: var(--teal-dark); text-decoration: none; }

.app-sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #102019, var(--sidebar));
  color: var(--sidebar-text);
  min-height: 100vh;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  flex-shrink: 0;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: #2b2114;
  font-weight: 700;
}

.brand small { display: block; color: #c9bba6; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-group {
  margin-top: 18px;
  margin-bottom: 6px;
  font-size: 12px;
  color: #c4a35a;
  letter-spacing: 0.4px;
}
.side-nav .nav-link {
  color: var(--sidebar-text);
  padding: 8px 10px;
  border-radius: 8px;
}
.side-nav .nav-link:hover,
.side-nav .nav-link.active { background: rgba(255,255,255,0.08); }

.app-shell { flex: 1; min-width: 0; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  background: rgba(243, 239, 230, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
}
.header-title h1 { font-size: 1.15rem; margin: 0; }
.header-title p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.header-user { margin-right: auto; display: flex; align-items: center; gap: 12px; }
.sidebar-toggle {
  display: none;
  border: 0;
  background: transparent;
  font-size: 22px;
}

.app-main { padding: 24px; }

.card-panel, .widget, .kpi, .table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}

.kpi strong { display: block; font-size: 1.4rem; margin-top: 6px; }
.kpi span { color: var(--muted); }

.grid-2, .grid-3, .grid-4 {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}
.grid-2 { grid-template-columns: 1fr 1fr; }

.chart-pie {
  width: min(100%, 340px);
  margin-inline: auto;
}
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.import-records {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

.import-record {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 16px;
}

.import-record.has-warning {
  border-color: #d9a441;
  background: #fffaf0;
}

.import-record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.import-record-grid {
  margin-bottom: 0;
}

.report-image-capture {
  padding: 24px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.report-image-capture.is-capturing {
  min-width: 900px;
}

.report-image-head {
  margin-bottom: 18px;
  text-align: center;
}

.report-image-head h2 {
  margin: 0 0 6px;
}

.report-image-head p {
  margin: 0;
  color: var(--muted);
}

.time-filter, .toolbar, .form-grid, .badge-row, .combo, .actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}
.form-grid label { display: flex; flex-direction: column; gap: 6px; }
.form-grid .wide { grid-column: 1 / -1; }
.combo { display: flex; gap: 8px; }
.check { flex-direction: row !important; align-items: center; gap: 8px; }

.segmented {
  display: flex;
  background: #efe6d8;
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}
.segmented label {
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.segmented input { display: none; }
.segmented input:checked + *,
.segmented label:has(input:checked) {
  background: var(--teal);
  color: #fff;
}

.btn, .btn-primary {
  background: var(--teal);
  border: 0;
  color: #fff;
  border-radius: 10px;
  padding: 8px 14px;
}
.btn-outline-secondary, .btn-outline-primary, .btn-outline-danger, .btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn-outline-danger { color: var(--danger); border-color: #f0b4ad; }
.btn-ghost { border: 0; }

.table { width: 100%; }
.table th { color: var(--muted); font-weight: 600; }
.table-wrap { overflow: auto; }

.payment-list { list-style: none; padding: 0; margin: 0; }
.payment-list li {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.payment-list small, .muted, .hint { color: var(--muted); }
.stat { padding: 12px; border-radius: 12px; min-width: 140px; }
.stat .count { font-size: 1.6rem; font-weight: 700; display: block; }
.stat.overdue { background: var(--overdue); }
.stat.upcoming { background: var(--upcoming); }
.is-overdue { background: #fff4f2; }
.warn-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-weight: 700;
}
.is-unknown, .form-control.is-unknown, .form-select.is-unknown {
  background: var(--warn) !important;
}
.hidden { display: none !important; }
.preview { max-width: 320px; border-radius: 12px; margin: 12px 0; }
.file-drop {
  display: grid;
  place-items: center;
  min-height: 140px;
  border: 1px dashed var(--gold);
  border-radius: 12px;
  cursor: pointer;
  margin-bottom: 12px;
}
.spinner { padding: 12px; color: var(--teal-dark); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.inline { display: inline; }
.error-list { color: var(--danger); }

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 10% 10%, #d7c39a 0, transparent 40%),
    linear-gradient(160deg, #16382d, #1c6b5a 50%, #f3efe6 50%);
}
.auth-card {
  width: min(420px, 92vw);
  background: var(--surface);
  padding: 32px;
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-brand h1 { margin: 10px 0 0; }
.auth-brand-name {
  margin: 6px 0 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent, #1c6b5a);
  letter-spacing: 0.02em;
}
.auth-brand > p:last-child { margin-top: 8px; }
.login-accounts { margin-top: 22px; font-size: 0.9rem; }
.login-accounts p { color: var(--muted); margin-bottom: 8px; }
.login-accounts .table { margin: 0; }

.print-head { margin-bottom: 18px; border-bottom: 2px solid var(--ink); }

body.is-picker {
  display: block;
}
body.is-picker .app-shell {
  min-height: 100vh;
}
body.is-picker .app-main {
  min-height: calc(100vh - var(--header-h));
  display: flex;
  align-items: center;
  justify-content: center;
}
.picker-page {
  width: min(1100px, 100%);
  margin: 0 auto;
  text-align: center;
}
.picker-lead {
  color: var(--muted);
  margin-bottom: 28px;
  font-size: 1.05rem;
}
.project-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 22px;
}
.project-tile {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  min-height: 240px;
  padding: 28px 22px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-align: right;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
a.project-tile:hover {
  transform: translateY(-6px);
  box-shadow: 0 18px 36px rgba(31, 26, 22, 0.14);
  color: var(--ink);
}
.tile-kicker {
  font-size: 0.8rem;
  color: var(--muted);
}
.project-tile strong {
  font-size: 1.45rem;
}
.project-tile span:last-child {
  color: var(--muted);
  line-height: 1.6;
}
.tile-salon { border-top: 6px solid #1c6b5a; }
.tile-shop { border-top: 6px solid #c4a35a; }
.tile-projects { border-top: 6px solid #3d5a80; }
.project-tile.is-locked {
  opacity: 0.45;
  background: #efe8dc;
  cursor: not-allowed;
}

@media (max-width: 992px) {
  .grid-2, .grid-3, .grid-4, .form-grid, .project-picker { grid-template-columns: 1fr 1fr; }
  .app-sidebar { position: fixed; right: 0; transform: translateX(110%); z-index: 30; transition: 0.2s ease; }
  .app-sidebar.open { transform: none; }
  .sidebar-toggle { display: block; }
  .app-sidebar.open + .app-shell::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(20, 38, 31, 0.35);
    z-index: 25;
  }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4, .form-grid, .project-picker { grid-template-columns: 1fr; }
  .app-main { padding: 16px; }
}
