/* ============================================================
   invoice.divi.ge — Complete Design System
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

:root {
  --ink:         #0B1220;
  --ink-soft:    #475569;
  --ink-faint:   #94A3B8;
  --canvas:      #F0F2F5;
  --surface:     #FFFFFF;
  --border:      #E4E7EC;
  --border-soft: #EEF1F5;
  --accent:      #2151D6;
  --accent-dark: #1A3FAD;
  --accent-soft: #EAF0FE;
  --success:      #16A34A;
  --success-soft: #DCFCE7;
  --danger:       #DC2626;
  --danger-soft:  #FEE2E2;
  --warn:         #D97706;
  --warn-soft:    #FEF3C7;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(15,23,42,.07);
  --shadow-md: 0 4px 16px rgba(15,23,42,.09);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  margin: 0; padding: 0;
  font-family: var(--font);
  font-size: 15px; line-height: 1.55;
  color: var(--ink); background: var(--canvas);
  padding-bottom: 64px;
}
@media (min-width: 1024px) { body { padding-bottom: 0; } }

a { color: var(--accent); text-decoration: none; }
h1,h2,h3,h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
p { margin: 0; }
.num   { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-faint); }
.soft  { color: var(--ink-soft); }

/* ── LAYOUT ── */
.si-wrap  { display: flex; min-height: 100vh; }
.si-main  { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* desktop sidebar */
.si { width: 220px; min-height: 100vh; background: #111827; flex-shrink: 0; display: none; flex-direction: column; }
@media (min-width: 1024px) { .si { display: flex; } }
.si-brand { display: flex; align-items: center; gap: 9px; padding: 14px 14px 12px; border-bottom: 1px solid rgba(255,255,255,.08); text-decoration: none; margin-bottom: 6px; }
.si-mark  { width: 26px; height: 26px; border-radius: 6px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex-shrink: 0; }
.si-brand span { color: #fff; font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.si-sec   { font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: rgba(255,255,255,.28); padding: 10px 14px 3px; }
.ni       { display: flex; align-items: center; gap: 9px; padding: 8px 14px; text-decoration: none; font-size: 13.5px; font-weight: 500; color: rgba(255,255,255,.65); transition: background .1s; }
.ni:hover { background: rgba(255,255,255,.07); color: #fff; }
.ni.nav-active { background: rgba(33,81,214,.3); color: #fff; border-left: 3px solid var(--accent); }
.ni svg   { flex-shrink: 0; opacity: .8; }
.si-foot  { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding: 10px 14px; }
.si-foot a { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.4); text-decoration: none; font-size: 13px; padding: 6px 0; }
.si-foot a:hover { color: #f87171; }

/* mobile topbar */
.tb  { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.97); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; }
@media (min-width: 1024px) { .tb { display: none; } }
.tb-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 800; font-size: 15px; color: var(--ink); }
.tb-mark  { width: 26px; height: 26px; border-radius: 6px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; }
.tb-btn   { background: var(--canvas); border: 1px solid var(--border); border-radius: 7px; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink-soft); }

/* mobile menu overlay */
.mo  { display: none; position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.5); }
.mo.open { display: flex; }
.ms  { width: min(260px, 82vw); background: #111827; height: 100%; display: flex; flex-direction: column; overflow-y: auto; }
.ms-head  { display: flex; justify-content: space-between; align-items: center; padding: 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.ms-head span { color: #fff; font-weight: 800; font-size: 15px; }
.ms-close { background: rgba(255,255,255,.1); border: none; color: #fff; width: 28px; height: 28px; border-radius: 6px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.ms-user  { padding: 10px 14px 12px; border-bottom: 1px solid rgba(255,255,255,.07); }
.ms-user-name  { color: #fff; font-weight: 600; font-size: 13.5px; }
.ms-user-email { color: rgba(255,255,255,.35); font-size: 11.5px; margin-top: 2px; }
.ms-user-role  { color: rgba(255,255,255,.4); font-size: 11.5px; margin-top: 2px; }
.ms-sec   { font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: rgba(255,255,255,.28); padding: 10px 14px 3px; }
.ms .ni   { border-bottom: 1px solid rgba(255,255,255,.04); }
.ms-foot  { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding: 10px 14px; }
.ms-foot a { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.4); text-decoration: none; font-size: 13px; padding: 7px 0; }
.ms-foot a:hover { color: #f87171; }

/* bottom tabbar */
.tbar { position: fixed; bottom: 0; left: 0; right: 0; height: 60px; background: #fff; border-top: 1px solid var(--border); display: flex; align-items: stretch; z-index: 50; box-shadow: 0 -2px 10px rgba(0,0,0,.06); }
@media (min-width: 1024px) { .tbar { display: none; } }
.tbar a   { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--ink-faint); font-size: 10px; font-weight: 600; -webkit-tap-highlight-color: transparent; position: relative; }
.tbar a.ta { color: var(--accent); }
.tbar a.ta::after { content: ''; position: absolute; top: 0; left: 25%; right: 25%; height: 2px; background: var(--accent); border-radius: 0 0 2px 2px; }
.tbar svg  { width: 20px; height: 20px; display: block; }
.tbar span { line-height: 1; }
.tfab { background: var(--accent); color: #fff !important; border-radius: 50%; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; align-self: center; flex-shrink: 0; flex: 0 0 44px !important; margin: 0 4px; box-shadow: 0 3px 10px rgba(33,81,214,.4); }
.tfab::after { display: none !important; }

/* ── PAGE ── */
.page-wrap { padding: 14px 14px 20px; max-width: 1600px; }
@media (min-width: 1024px) { .page-wrap { padding: 28px 32px; } }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }

/* ── CARD ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-sm); }
@media (min-width: 640px) { .card { padding: 18px 20px; } }
.card + .card { margin-top: 12px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border-soft); }

/* ── STAT ── */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 600px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; }
.stat-card .label { font-size: 11.5px; color: var(--ink-faint); font-weight: 600; margin-bottom: 6px; }
.stat-card .value { font-size: 24px; font-weight: 800; }
.stat-card.accent  .value { color: var(--accent); }
.stat-card.success .value { color: var(--success); }
.stat-card.warn    .value { color: var(--warn); }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-family: inherit; font-size: 14px; font-weight: 600; padding: 10px 16px; border-radius: var(--radius-sm); border: 1.5px solid transparent; cursor: pointer; text-decoration: none; line-height: 1.2; transition: opacity .12s, transform .05s; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.btn:active { transform: scale(.97); }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary   { background: var(--accent);   color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-success   { background: var(--success);  color: #fff; }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-warning   { background: var(--warn);     color: #fff; }
.btn-secondary { background: var(--surface);  color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { background: var(--canvas); }
.btn-ghost     { background: transparent;     color: var(--ink-soft); border-color: transparent; }
.btn-ghost:hover { background: var(--canvas); }
.btn-sm    { padding: 6px 11px; font-size: 13px; border-radius: 6px; }
.btn-lg    { padding: 13px 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ── FORMS ── */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.field .hint  { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }

/* INPUT — ყველაზე მნიშვნელოვანი: box-sizing + width:100% + min-width:0 */
input, select, textarea {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  font-family: inherit;
  font-size: 16px;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 80px; font-size: 15px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(33,81,214,.1);
}
input:disabled, select:disabled { background: var(--canvas); color: var(--ink-faint); }
input[type=checkbox] { width: auto; min-width: auto; padding: 0; }
input[type=file]     { padding: 8px; font-size: 14px; cursor: pointer; }

/* GRID — mobile-first, ყოველთვის multi-column */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ვიწრო ეკრანებზე ვამცირებთ */
@media (max-width: 500px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 340px) {
  .grid-3 { grid-template-columns: 1fr; }
}

/* grid-ის შიგნით ველები ყოველთვის სრული სიგანე */
.grid-2 > *, .grid-3 > * { min-width: 0; }
.grid-2 input, .grid-2 select, .grid-2 textarea,
.grid-3 input, .grid-3 select, .grid-3 textarea { width: 100%; }

/* ── BADGES ── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-scheduled   { background: #E0E7FF; color: #3730A3; }
.badge-confirmed   { background: var(--accent-soft); color: var(--accent-dark); }
.badge-in_progress { background: #FEF3C7; color: #92400E; }
.badge-completed   { background: var(--success-soft); color: #15803D; }
.badge-cancelled   { background: var(--danger-soft); color: #B91C1C; }
.badge-no_show     { background: #F3F4F6; color: #6B7280; }
.badge-draft    { background: #F1F5F9; color: #64748B; }
.badge-sent     { background: var(--accent-soft); color: var(--accent-dark); }
.badge-paid     { background: var(--success-soft); color: #15803D; }
.badge-overdue  { background: var(--warn-soft); color: #92400E; }

/* ── STATUS PILLS ── */
.status-pills { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.status-pills::-webkit-scrollbar { display: none; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 7px 13px; border-radius: 999px; background: var(--surface); border: 1.5px solid var(--border); color: var(--ink-soft); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; flex-shrink: 0; }
.status-pill.active { background: var(--ink); border-color: var(--ink); color: white; }
.status-pill .count { background: rgba(0,0,0,.08); border-radius: 999px; padding: 0 6px; font-size: 11px; }
.status-pill.active .count { background: rgba(255,255,255,.2); }

/* ── TABLES ── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; }
table.dt th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); padding: 11px 14px; background: var(--canvas); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.dt td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); font-size: 14px; vertical-align: middle; }
table.dt tr:last-child td { border-bottom: none; }
table.dt tr.clickable { cursor: pointer; }
table.dt tr.clickable:hover { background: var(--canvas); }
.td-actions { text-align: right; white-space: nowrap; }
.td-no-wrap { white-space: nowrap; }

.mobile-cards  { display: block; }
.desktop-table { display: none; }
@media (min-width: 1024px) {
  .mobile-cards  { display: none; }
  .desktop-table { display: block; }
}

/* ── ALERTS ── */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 12px; }
.alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--success-soft); color: #15803D; }
.alert-error   { background: var(--danger-soft);  color: #B91C1C; }
.alert-info    { background: var(--accent-soft);  color: var(--accent-dark); }
.alert-warn    { background: var(--warn-soft);    color: #92400E; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state .icon { width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.empty-state .icon svg { width: 24px; height: 24px; }
.empty-state h3 { margin-bottom: 6px; }
.empty-state p  { color: var(--ink-faint); font-size: 13.5px; margin-bottom: 14px; }

/* ── PATIENT AVATAR ── */
.patient-avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; flex-shrink: 0; }

/* ── UTILITIES ── */
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.flex-center  { display: flex; align-items: center; gap: 10px; }
.stack        { display: flex; flex-direction: column; gap: 10px; }
hr.divider    { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.tag { display: inline-block; padding: 2px 8px; background: var(--canvas); border: 1px solid var(--border); border-radius: 4px; font-size: 12px; color: var(--ink-soft); }

/* SVG guard */
svg { max-width: 100%; }

/* ── PRINT ── */
@media print {
  .si, .tb, .tbar, .mo, .no-print { display: none !important; }
  body { padding: 0; background: white; }
  .si-wrap { display: block; }
}

/* ── FILE UPLOAD BOX ── */
.file-box { border: 2px dashed var(--border); border-radius: var(--radius-md); padding: 14px; text-align: center; position: relative; cursor: pointer; transition: border-color .15s; }
.file-box:hover { border-color: var(--accent); }
.file-box input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-box img { max-height: 60px; max-width: 120px; object-fit: contain; display: block; margin: 0 auto 8px; }
.file-box .label { font-size: 12px; color: var(--ink-faint); }
