/* სსა რეგისტრაცია — შიდა სისტემა სერვის ცენტრისთვის */
:root {
  --ink: #1b2340;
  --paper: #f3f5f8;
  --sheet: #ffffff;
  --rule: #d9dee7;
  --rule-strong: #b9c1cf;
  --muted: #5a6378;
  --stamp: #2d3a8c;
  --stamp-soft: #e9ecf8;
  --ok: #1e7650;
  --ok-soft: #e6f3ec;
  --warn: #a35f05;
  --warn-soft: #fbf1e1;
  --bad: #b3261e;
  --bad-soft: #fbeae8;
  --void: #737a8d;
  --focus: #f2b705;
  --radius: 6px;
  --sans: "Noto Sans Georgian", "FiraGO", "BPG Arial", "Sylfaen", "DejaVu Sans", system-ui, sans-serif;
  --serif: "Noto Serif Georgian", "BPG Nino Elite", "Sylfaen", "DejaVu Serif", Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  font-variant-numeric: tabular-nums;
}
a { color: var(--stamp); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font: 600 1.75rem/1.2 var(--serif); letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; font-weight: 650; margin-bottom: .75rem; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.nowrap { white-space: nowrap; }
.push-right { margin-left: auto; }
.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; }

/* ---------------------------------------------------------- ზედა ზოლი */
.topbar {
  background: var(--ink);
  color: #fff;
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 20px; min-height: 58px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 10px 0; }
.brand-mark {
  width: 30px; height: 30px; border: 2px solid #fff; border-radius: 4px;
  display: grid; place-items: center; font: 700 13px/1 var(--sans);
}
.brand-name { font-weight: 650; letter-spacing: .01em; }
.brand-company { display: block; font-size: 12px; color: #b9c2e0; font-weight: 400; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a {
  color: #d8def0; text-decoration: none; padding: 8px 12px; border-radius: var(--radius);
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.nav a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, .14); }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #d8def0; }
.userbox a { color: #d8def0; }
.linkbtn {
  background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline;
  text-underline-offset: 2px; cursor: pointer;
}

.testmode {
  background: repeating-linear-gradient(-45deg, #fde7b0 0 14px, #fbdf98 14px 28px);
  color: #5b3a00; text-align: center; padding: 7px 16px; font-size: 14px;
}
.testmode code { background: rgba(255, 255, 255, .6); padding: 1px 6px; border-radius: 3px; word-break: break-all; }

/* ---------------------------------------------------------- განლაგება */
main { max-width: 1180px; margin: 0 auto; padding: 28px 20px 64px; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 22px;
}
.page-head .sub { margin: 6px 0 0; color: var(--muted); }
.back { display: inline-block; margin-bottom: 10px; font-size: 14px; }
.section { margin-top: 34px; }
.section:first-child { margin-top: 0; }
.panel {
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 20px 22px;
}
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.grid-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.stack > * + * { margin-top: 16px; }

/* ---------------------------------------------------------- შეტყობინებები */
.flashes { margin-bottom: 22px; display: grid; gap: 10px; }
.flash {
  border-left: 4px solid var(--stamp); background: var(--stamp-soft); padding: 11px 14px;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.flash.success { border-color: var(--ok); background: var(--ok-soft); }
.flash.error { border-color: var(--bad); background: var(--bad-soft); }
.flash.warning { border-color: var(--warn); background: var(--warn-soft); }
.panel > .flash { margin: 0 0 12px; }

/* ---------------------------------------------------------- სტატუსის შტამპი */
.stamp {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid currentColor; border-radius: 4px;
  padding: 1px 8px; font-size: 13px; font-weight: 600; line-height: 1.6;
  white-space: nowrap; letter-spacing: .02em; background: var(--sheet);
}
.stamp-registered { color: var(--ok); }
.stamp-failed { color: var(--bad); }
.stamp-unknown, .stamp-pending { color: var(--warn); }
.stamp-deleted, .stamp-deregistered { color: var(--void); border-style: dashed; }
.stamp-new { color: var(--stamp); }
.stamp-ok { color: var(--ok); }
.stamp-rejected, .stamp-not_sent { color: var(--bad); }
.stamp-big { font-size: 15px; padding: 4px 12px; border-width: 2px; }

/* სალარო ადგილები: რამდენი აპარატი რეგისტრირდა განცხადების რაოდენობიდან */
.slots { display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; }
.slot {
  width: 11px; height: 15px; border: 1.5px solid var(--rule-strong); border-radius: 2px; background: var(--sheet);
}
.slot.filled { background: var(--ok); border-color: var(--ok); }
.slot.waiting { background: var(--warn-soft); border-color: var(--warn); }
.slots-label { margin-left: 6px; font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------- მაჩვენებლები */
.tally {
  display: flex; flex-wrap: wrap; background: var(--sheet); border: 1px solid var(--rule);
  border-radius: var(--radius); margin-bottom: 30px;
}
.tally a {
  flex: 1 1 200px; padding: 16px 20px; text-decoration: none; color: var(--ink);
  border-right: 1px solid var(--rule); display: flex; align-items: baseline; gap: 12px;
}
.tally a:last-child { border-right: 0; }
.tally a:hover { background: #f8f9fc; }
.tally b { font: 600 1.6rem/1 var(--serif); }
.tally span { color: var(--muted); font-size: 14px; }
.tally .is-alert b { color: var(--bad); }
.tally .is-todo b { color: var(--stamp); }

/* ---------------------------------------------------------- ცხრილები */
.table-wrap { overflow-x: auto; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
th { font-size: 13px; font-weight: 600; color: var(--muted); background: #f8f9fc; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfd; }
td.actions { white-space: nowrap; text-align: right; }
td.num { white-space: nowrap; }
td.reason { min-width: 240px; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 10px; }

/* ---------------------------------------------------------- ფორმები */
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.hint { display: block; font-weight: 400; font-size: 13px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=search], input[type=date], input[type=datetime-local],
input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--rule-strong); border-radius: var(--radius); padding: 8px 10px; min-height: 40px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--stamp); outline: 2px solid var(--stamp-soft); outline-offset: 0; }
.field { margin-bottom: 14px; }
.field.has-error input, .field.has-error select { border-color: var(--bad); background: #fffafa; }
.field .err { color: var(--bad); font-size: 13px; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .wide { grid-column: 1 / -1; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { max-width: 320px; }
.filters select, .filters input[type=date] { width: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--rule-strong); border-radius: 999px; padding: 4px 12px; font-size: 14px;
  text-decoration: none; color: var(--ink); background: var(--sheet);
}
.chip[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.checkbox { display: flex; gap: 8px; align-items: center; font-weight: 400; }

/* ---------------------------------------------------------- ღილაკები */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 14px/1.2 var(--sans); padding: 10px 16px; min-height: 40px;
  border-radius: var(--radius); border: 1.5px solid var(--stamp); background: var(--stamp); color: #fff;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #24307a; border-color: #24307a; }
.btn[disabled], .btn.is-busy { opacity: .6; cursor: progress; }
.btn-quiet { background: var(--sheet); color: var(--stamp); }
.btn-quiet:hover { background: var(--stamp-soft); }
.btn-danger { background: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: #8f1d17; border-color: #8f1d17; }
.btn-danger-quiet { background: var(--sheet); color: var(--bad); border-color: var(--bad); }
.btn-danger-quiet:hover { background: var(--bad-soft); }
.btn-sm { padding: 5px 10px; min-height: 30px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------- დეტალები */
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 22px; margin: 0; }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts dd.strong { font-weight: 600; }
.regid { font: 600 2.4rem/1 var(--serif); letter-spacing: .02em; margin-bottom: 22px; }
.regid-label { color: var(--muted); font-size: 14px; display: block; margin-bottom: 6px; }
.danger-zone { border: 1px solid #ecc6c2; background: #fffbfa; border-radius: var(--radius); padding: 18px 20px; }
.danger-zone h2 { color: var(--bad); }
.note-box { white-space: pre-wrap; background: #f8f9fc; border: 1px solid var(--rule); border-radius: var(--radius); padding: 10px 12px; font-size: 14px; }
.error-text { color: var(--bad); }
.xml {
  background: #0f1730; color: #dfe6ff; padding: 14px 16px; border-radius: var(--radius); overflow-x: auto;
  font: 13px/1.5 "DejaVu Sans Mono", Consolas, monospace; white-space: pre; max-height: 540px;
}
.xml.wrap { white-space: pre-wrap; word-break: normal; overflow-wrap: anywhere; }
details.panel > summary { cursor: pointer; font-weight: 650; list-style-position: inside; }
details.panel[open] > summary { margin-bottom: 12px; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 14px; }
.pager span { color: var(--muted); margin-right: 6px; }

/* ---------------------------------------------------------- შესვლა */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login {
  width: 100%; max-width: 380px; background: var(--sheet); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 30px 28px;
}
.login .brand-mark { border-color: var(--ink); color: var(--ink); margin-bottom: 18px; }
.login h1 { font-size: 1.5rem; margin-bottom: 6px; }
.login .btn { width: 100%; margin-top: 6px; }

/* ---------------------------------------------------------- მობილური */
@media (max-width: 860px) {
  .grid-2, .grid-even { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .topbar-inner { gap: 10px; padding: 0 16px; }
  .nav { order: 3; flex-basis: 100%; padding-bottom: 8px; }
  .nav a { padding: 6px 10px; }
  .table-wrap table { min-width: 640px; }
  .table-wrap table.compact { min-width: 0; }
  .userbox { margin-left: auto; }
  main { padding: 20px 16px 48px; }
  h1 { font-size: 1.45rem; }
  .tally a { border-right: 0; border-bottom: 1px solid var(--rule); }
  .tally a:last-child { border-bottom: 0; }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .facts dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .topbar, .testmode, .btn, form, .pager { display: none !important; }
  body { background: #fff; }
}

/* ---------------------------------------------------------- ადმინისტრირება / თანამშრომლები */
.topbar-admin { background: #0f3d36; }
.topbar-admin .nav a[aria-current="page"] { background: rgba(255, 255, 255, .16); }
.area-switch {
  border: 1px solid rgba(255, 255, 255, .45); border-radius: 999px; padding: 3px 12px;
  text-decoration: none; color: #fff !important; white-space: nowrap;
}
.area-switch:hover { background: rgba(255, 255, 255, .1); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: .75rem; }
.section-head h2 { margin: 0; }
.perm-form { display: grid; gap: 2px; min-width: 210px; }
.perm-form .checkbox { font-size: 13px; margin: 0; }
.perm-form .btn { justify-self: start; margin-top: 6px; }
.perm-set { border: 0; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 6px 22px; }
.perm-set legend { font-size: 14px; font-weight: 600; margin-bottom: 6px; padding: 0; }
.perm-set .hint { flex-basis: 100%; }
.inline-details { margin-top: 8px; text-align: right; }
.inline-details summary { cursor: pointer; font-size: 13px; color: var(--stamp); }
.inline-details form { margin-top: 8px; }
.inline-details input[type=password] { width: 170px; min-height: 30px; padding: 4px 8px; }
.row-end { justify-content: flex-end; }
tr.is-muted td { color: var(--muted); }
.perm-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.perm-list li { padding-left: 24px; position: relative; }
.perm-list li::before { position: absolute; left: 0; top: 0; font-weight: 700; }
.perm-list li.yes::before { content: "✓"; color: var(--ok); }
.perm-list li.no { color: var(--muted); }
.perm-list li.no::before { content: "—"; color: var(--muted); }
.login-admin { border-top: 5px solid #0f3d36; }
.login-admin .brand-mark { border-color: #0f3d36; color: #0f3d36; }
.login-admin .btn { background: #0f3d36; border-color: #0f3d36; }
.login-admin .btn:hover { background: #0a2e29; border-color: #0a2e29; }
.login-switch { margin: 16px 0 0; text-align: center; font-size: 14px; }
.area-admin .login-wrap { background: #e9f0ee; }
/* ადმინის პანელი უფრო ფართოა — მეტი სვეტი ცხრილებში და მენიუ ერთ ხაზზე */
.topbar-admin .topbar-inner, .area-admin main { max-width: 1320px; }
.topbar-admin .nav a { padding: 8px 10px; }

/* ---------------------------------------------------------- ენის გადამრთველი */
.lang-switch { display: inline-flex; border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px; overflow: hidden; }
.lang-switch a {
  padding: 2px 9px; font-size: 12px; font-weight: 600; letter-spacing: .03em; text-decoration: none;
  color: #d8def0 !important;
}
.lang-switch a[aria-current="true"] { background: rgba(255, 255, 255, .9); color: var(--ink) !important; }
.topbar-admin .lang-switch a[aria-current="true"] { color: #0f3d36 !important; }
.login-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.login-top .brand-mark { margin-bottom: 0; }
.login .lang-switch { border-color: var(--rule-strong); }
.login .lang-switch a { color: var(--muted) !important; }
.login .lang-switch a[aria-current="true"] { background: var(--ink); color: #fff !important; }
.login-admin .lang-switch a[aria-current="true"] { background: #0f3d36; }
/* ინგლისურისთვის ლათინური შრიფტი */
.lang-en { --sans: "Noto Sans", "Noto Sans Georgian", system-ui, "Segoe UI", Arial, sans-serif;
           --serif: "Noto Serif", "Noto Serif Georgian", Georgia, serif; }
