/* ქართული CRM-ის საბაზისო სტილი. ფონტი: <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Georgian:wght@400;500;600;700&display=swap" rel="stylesheet"> */
:root {
  --font: 'Noto Sans Georgian', 'BPG Arial', 'Sylfaen', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;

  /* Synkor — ღია თემა */
  --bg: #F6F7F4;
  --surface: #FFFFFF;
  --surface-2: #E9EDEA;
  --border: #D5DCD8;
  --text: #13262A;
  --text-muted: #4E6468;

  --primary: #0E3B43;
  --primary-hover: #1D5C66;
  --primary-soft: #DCEAEC;
  --on-primary: #FFFFFF;
  --accent: #F0A531;
  --success: #1F7A52;  --success-soft: #E3F1EA;
  --warning: #9A5F12;  --warning-soft: #FCEFD9;
  --danger:  #B23A27;  --danger-soft:  #F8E4E0;

  /* გვერდითი მენიუ ყოველთვის ბრენდის ზღვისფერშია */
  --side-bg: #0E3B43; --side-text: #DCE7E8; --side-muted: #8FB0B4; --side-hover: #FFFFFF12; --side-active: #FFFFFF1A;

  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px #0E3B431A;
  --shadow-lg: 0 12px 32px #0E3B4329;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  color-scheme: light;
}

/* Synkor — მუქი თემა (ზღვისფერი, არა შავი) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E3B43; --surface: #13474F; --surface-2: #0A2B31; --border: #2A5A62;
    --text: #F6F7F4; --text-muted: #B8CBCC;
    --primary: #F0A531; --primary-hover: #F5B955; --primary-soft: #4A3A1A; --on-primary: #0E3B43;
    --success: #5CC08F; --success-soft: #16463A; --warning: #F0A531; --warning-soft: #4A3A1A; --danger: #F08A78; --danger-soft: #4A2620;
    --side-bg: #0A2B31;
    --shadow: 0 1px 2px #00000040; --shadow-lg: 0 12px 32px #00000066;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E3B43; --surface: #13474F; --surface-2: #0A2B31; --border: #2A5A62;
  --text: #F6F7F4; --text-muted: #B8CBCC;
  --primary: #F0A531; --primary-hover: #F5B955; --primary-soft: #4A3A1A; --on-primary: #0E3B43;
  --success: #5CC08F; --success-soft: #16463A; --warning: #F0A531; --warning-soft: #4A3A1A; --danger: #F08A78; --danger-soft: #4A2620;
  --side-bg: #0A2B31;
  --shadow: 0 1px 2px #00000040; --shadow-lg: 0 12px 32px #00000066;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.6;
  color: var(--text); background: var(--bg);
}
/* ქართულს დახრილი არ აქვს — em/i ხაზგასმით ჩანაცვლება */
em, i { font-style: normal; font-weight: 600; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
/* მთავრული სათაურებისთვის — მხოლოდ შეგნებულად */
.mtavruli { text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--side-bg); color: var(--side-text); border-right: 1px solid #FFFFFF14; padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { font-weight: 700; font-size: 16px; padding: 6px 10px 20px; color: #FFFFFF; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); color: var(--side-text); }
.nav a:hover { background: var(--side-hover); color: #FFFFFF; text-decoration: none; }
.nav a.active { background: var(--side-active); color: #FFFFFF; font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav .group { color: var(--side-muted) !important; }
.nav .group { font-size: 12px; color: var(--text-muted); padding: 14px 10px 4px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.content { padding: 20px; }
.btn.menu-toggle { display: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .content { padding: 12px; }
  .btn.menu-toggle { display: inline-flex; }
}

/* ---------- Card / stat ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--text-muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.btn.loading { pointer-events: none; opacity: .7; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.field .req::after { content: ' *'; color: var(--danger); }
.field .hint { font-size: 12px; color: var(--text-muted); }
.field .err { font-size: 12px; color: var(--danger); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px; min-height: 36px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger); }
textarea { min-height: 80px; resize: vertical; }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { position: sticky; top: 0; background: var(--surface-2); font-size: 13px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.wrap { overflow-wrap: anywhere; min-width: 160px; }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.empty { padding: 40px 16px; text-align: center; color: var(--text-muted); }

/* ---------- Badge / alert ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-muted); white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }

/* ---------- Modal / toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: flex-start; justify-content: center; padding: 6vh 12px; z-index: 100; overflow-y: auto; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 640px; box-shadow: var(--shadow-lg); }
.modal-head, .modal-foot { padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.modal-head { border-bottom: 1px solid var(--border); }
.modal-foot { border-top: 1px solid var(--border); justify-content: flex-end; }
.modal-body { padding: 18px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 200; }
.toast { background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: var(--radius); box-shadow: var(--shadow-lg); max-width: 360px; }
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--success); color: #fff; }

/* ---------- Auth page ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 360px; display: grid; gap: 4px; }
.auth-card h1 { text-align: center; margin-bottom: 12px; }

/* ---------- Print (A4) ---------- */
@media print {
  @page { size: A4; margin: 15mm; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .sidebar, .topbar, .toolbar, .no-print, .btn { display: none !important; }
  .app { display: block; }
  .card, .table-wrap { border: 0; box-shadow: none; padding: 0; }
  .table th { position: static; background: #eee !important; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tr { break-inside: avoid; }
}

/* brand logo in sidebar */
.brand svg { width: 100%; height: auto; display: block; }
/* proposals */
.editor { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.sum-card { position: sticky; top: calc(var(--topbar-h) + 16px); }
.sum-line { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; }
.sum-total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 20px; font-weight: 700; }
.items-t td { vertical-align: top; }
.items-t input { min-height: 34px; padding: 5px 8px; }
.stage-row { display: grid; grid-template-columns: 1fr 90px 120px 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.save-state { font-size: 12px; color: var(--text-muted); }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } .sum-card { position: static; } .stage-row { grid-template-columns: 1fr 70px 36px; } .stage-row .amt { display: none; } }

.theme-btn { min-width: 34px; }
/* კითხვარი (ტექ. დავალება) */
.q { padding: 14px 0; border-bottom: 1px solid var(--border); }
.q:last-child { border-bottom: 0; }
.q-l { display: flex; gap: 10px; font-weight: 600; }
.q-n { flex: 0 0 24px; height: 24px; border-radius: 50%; background: var(--warning-soft); color: var(--warning); display: grid; place-items: center; font-size: 12px; }
.q-h { color: var(--text-muted); font-size: 13px; margin: 2px 0 0 34px; }
.q textarea, .q > input { margin: 8px 0 0 34px; width: calc(100% - 34px); }
.q-opts { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0 34px; }
.q-o { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-size: 14px; }
.q-o input { width: auto; min-height: 0; }
.q-o:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.busy { pointer-events: none; opacity: .6; }
/* ---------- datepicker (assets/js/datepicker.js) ---------- */
.dp-input { padding-right: 38px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23778B8E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='3'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; font-variant-numeric: tabular-nums; }
.dp { position: absolute; z-index: 300; width: 300px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 12px; font-size: 14px; }
.dp[hidden] { display: none; }
.dp button { font: inherit; color: inherit; cursor: pointer; }
.dp-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dp-h button { border: 0; background: none; width: 34px; height: 34px; border-radius: 8px; font-size: 20px; line-height: 1; }
.dp-h .dp-t { width: auto; font-size: 15px; font-weight: 600; padding: 0 12px; }
.dp-h button:hover { background: var(--surface-2); }
.dp-w, .dp-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.dp-w span { font-size: 11px; color: var(--text-muted); padding: 4px 0; font-weight: 600; }
.dp-g button { height: 36px; border: 0; background: none; border-radius: 9px; font-variant-numeric: tabular-nums; }
.dp-g button:hover { background: var(--surface-2); }
.dp-g button.we { color: var(--text-muted); }
.dp-g button.today { box-shadow: inset 0 0 0 1.5px var(--accent); font-weight: 600; }
.dp-g button.sel { background: var(--primary); color: var(--on-primary); font-weight: 700; box-shadow: none; }
.dp-f { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.dp-f button { border: 0; background: none; padding: 6px 10px; border-radius: 8px; font-weight: 600; }
.dp-f button:hover { background: var(--surface-2); }
.dp-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dp-months button { height: 44px; border: 1px solid var(--border); background: none; border-radius: 9px; }
.dp-months button:hover { background: var(--surface-2); }
.dp-months button.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
@media (max-width: 560px) {
  .dp { position: fixed; left: 8px !important; right: 8px; top: auto !important; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); width: auto; padding: 14px; }
  .dp-g button { height: 44px; }
}
/* მთავარი დაფა */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.att { display: grid; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.att:last-child { border-bottom: 0; }
.att span { font-size: 13px; color: var(--warning); }
.att:hover strong { text-decoration: underline; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
/* შესვლის გვერდები */
.auth-logo { width: 150px; margin: 0 auto 20px; color: var(--text); }
.auth-logo svg { width: 100%; height: auto; display: block; }
.otp { font-family: var(--font-mono); font-size: 28px; letter-spacing: 12px; text-align: center; padding: 10px 8px 10px 20px; }
