/* Файл css/style.css — тактична тема інтерфейсу (Military Tech) */

:root {
  --tac-bg: #0F1410;
  --tac-panel: #171F19;
  --tac-panel-2: #1C261F;
  --tac-line: #263329;
  --tac-line-hi: #34463A;
  --tac-olive: #4A5D23;
  --tac-olive-hi: #5B7230;
  --tac-gold: #D4AF37;
  --tac-gold-dim: rgba(212, 175, 55, 0.35);
  --tac-green: #22C55E;
  --tac-yellow: #EAB308;
  --tac-red: #EF4444;
  --tac-text: #E4EBE5;
  --tac-muted: #8C9C91;
  --radius: 5px;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

html { background: var(--tac-bg); }
body {
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(74, 93, 35, 0.16), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 4px),
    var(--tac-bg);
  color: var(--tac-text);
}

/* ---------- Скролбари ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--tac-olive) var(--tac-bg); }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--tac-bg); }
*::-webkit-scrollbar-thumb { background: var(--tac-olive); border: 2px solid var(--tac-bg); border-radius: 2px; }
*::-webkit-scrollbar-thumb:hover { background: var(--tac-olive-hi); }

::selection { background: var(--tac-olive); color: #fff; }

:focus-visible { outline: 2px solid var(--tac-gold); outline-offset: 2px; }

/* ---------- Шапка й герб ---------- */
.mil-header { box-shadow: 0 1px 0 rgba(212, 175, 55, 0.12); }
.emblem {
  display: grid; place-items: center; width: 60px; height: 64px; flex-shrink: 0;
  border: 1px solid var(--tac-line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--tac-panel-2), var(--tac-panel));
  box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.12);
}
.emblem img { width: 52px; height: 52px; object-fit: contain; }

.tac-clock {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px;
  border: 1px solid var(--tac-line); border-radius: var(--radius); background: var(--tac-panel);
}

/* ---------- Військові рамки: кутові скоби ---------- */
.panel {
  background: var(--tac-panel); border: 1px solid var(--tac-line); border-radius: var(--radius);
}
.mil-frame { position: relative; }
.mil-frame::before,
.mil-frame::after {
  content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none;
  border-color: var(--tac-gold-dim); border-style: solid;
}
.mil-frame::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; border-top-left-radius: var(--radius); }
.mil-frame::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; border-bottom-right-radius: var(--radius); }

.icon-badge {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--tac-olive); border-radius: var(--radius);
  background: rgba(74, 93, 35, 0.22); color: var(--tac-gold);
}

/* ---------- Аналітичні картки ---------- */
.stat-card { padding: 16px; display: flex; flex-direction: column; gap: 6px; min-height: 128px; }
.stat-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--tac-muted); }
.stat-value { font-family: var(--font-mono); font-size: 40px; font-weight: 700; line-height: 1; margin-top: auto;
  font-variant-numeric: tabular-nums; }
.stat-note { font-size: 12px; color: var(--tac-muted); }

/* ---------- Вкладки ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--tac-line); }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; margin-bottom: -1px;
  font-size: 14px; font-weight: 600; color: var(--tac-muted); background: transparent;
  border: 1px solid transparent; border-bottom: 2px solid transparent; border-radius: var(--radius) var(--radius) 0 0;
}
.tab:hover { color: var(--tac-text); }
.tab[aria-selected="true"] { color: var(--tac-gold); border-bottom-color: var(--tac-gold); background: var(--tac-panel); border-color: var(--tac-line) var(--tac-line) var(--tac-gold); }
.tab[hidden] { display: none; }

/* ---------- Кнопки й поля ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; min-height: 38px;
  font-size: 14px; font-weight: 600; border-radius: var(--radius); border: 1px solid transparent;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--tac-olive); color: #F2F5EC; border-color: var(--tac-olive-hi); }
.btn-primary:hover:not(:disabled) { background: var(--tac-olive-hi); }
.btn-ghost { background: transparent; color: var(--tac-text); border-color: var(--tac-line-hi); }
.btn-ghost:hover:not(:disabled) { border-color: var(--tac-gold); color: var(--tac-gold); }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 12px; gap: 6px; }
.btn-danger { background: transparent; color: #F59C9C; border-color: rgba(239, 68, 68, 0.45); }
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.12); }
.btn-gold { background: transparent; color: var(--tac-gold); border-color: var(--tac-gold-dim); }
.btn-gold:hover:not(:disabled) { background: rgba(212, 175, 55, 0.12); }
.btn-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius);
  color: var(--tac-muted); border: 1px solid transparent; }
.btn-icon:hover { color: var(--tac-text); border-color: var(--tac-line-hi); }

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--tac-muted); }
.field input, .select, .search input {
  width: 100%; min-height: 40px; padding: 8px 10px; font-size: 14px; color: var(--tac-text);
  background: var(--tac-bg); border: 1px solid var(--tac-line-hi); border-radius: var(--radius);
}
.field input[type="datetime-local"] { font-family: var(--font-mono); color-scheme: dark; }
.field input:focus, .select:focus, .search input:focus { border-color: var(--tac-gold); outline: none; }
.select { width: auto; min-width: 170px; color-scheme: dark; }
.search { position: relative; display: flex; align-items: center; flex: 1 1 260px; min-width: 220px; max-width: 420px; }
.search i, .search svg { position: absolute; left: 10px; }
.search input { padding-left: 34px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }

.alert { padding: 10px 12px; border-radius: var(--radius); font-size: 13px; margin-bottom: 10px; }
.alert-red { background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.4); color: #F8B4B4; }

/* ---------- Таблиці ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--tac-line); border-radius: var(--radius); }
.tac-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tac-table th {
  position: sticky; top: 0; z-index: 1; text-align: left; vertical-align: bottom; padding: 10px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--tac-muted); background: var(--tac-panel-2); border-bottom: 1px solid var(--tac-line-hi);
  user-select: none;
}
.tac-table th[data-sort] { cursor: pointer; }
.tac-table th[data-sort]:hover { color: var(--tac-text); }
.tac-table th[aria-sort="ascending"]::after { content: " ▲"; color: var(--tac-gold); }
.tac-table th[aria-sort="descending"]::after { content: " ▼"; color: var(--tac-gold); }
.tac-table td { padding: 10px; border-bottom: 1px solid var(--tac-line); vertical-align: middle; }
.tac-table tbody tr:hover { background: rgba(74, 93, 35, 0.10); }
.tac-table tbody tr:last-child td { border-bottom: 0; }
.tac-table .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tac-table .sub { display: block; margin-top: 2px; font-size: 11px; color: var(--tac-muted); }
.tac-table .actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 150px; }
.tac-table .name-cell { min-width: 190px; }
.row-overdue { box-shadow: inset 3px 0 0 var(--tac-red); }
.row-warning { box-shadow: inset 3px 0 0 var(--tac-yellow); }
.empty { padding: 28px; text-align: center; color: var(--tac-muted); font-size: 14px; }

.pass-no { color: var(--tac-gold); font-weight: 700; }
.rank { display: inline-block; padding: 2px 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.03em;
  border: 1px solid var(--tac-line-hi); border-radius: 3px; color: var(--tac-text); white-space: nowrap; }

/* ---------- Статуси з пульсацією ---------- */
.status { display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px 3px 8px; font-size: 12px; font-weight: 600;
  border-radius: 3px; border: 1px solid currentColor; white-space: nowrap; }
.status .dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.status.pulse .dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid currentColor;
  animation: tac-pulse 1.6s ease-out infinite;
}
.tone-green { color: var(--tac-green); background: rgba(34, 197, 94, 0.08); }
.tone-yellow { color: var(--tac-yellow); background: rgba(234, 179, 8, 0.10); }
.tone-red { color: var(--tac-red); background: rgba(239, 68, 68, 0.10); }
.tone-gold { color: var(--tac-gold); background: rgba(212, 175, 55, 0.08); }
.tone-olive { color: #A9C26A; background: rgba(74, 93, 35, 0.25); }
.tone-muted { color: var(--tac-muted); background: transparent; }
.status.tone-red.pulse { animation: tac-blink 1.2s steps(2, end) infinite; }

@keyframes tac-pulse {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(1.9); opacity: 0; }
}
@keyframes tac-blink {
  0%, 100% { background: rgba(239, 68, 68, 0.10); }
  50% { background: rgba(239, 68, 68, 0.24); }
}

.countdown { font-family: var(--font-mono); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.countdown.tone-green, .countdown.tone-yellow, .countdown.tone-red, .countdown.tone-muted { background: transparent; }

/* ---------- Модальні вікна ---------- */
.tac-dialog { width: min(560px, calc(100vw - 32px)); padding: 0; border: 0; background: transparent; color: var(--tac-text); }
.tac-dialog::backdrop { background: rgba(5, 8, 6, 0.78); backdrop-filter: blur(2px); }
.tac-dialog[open] { animation: tac-appear .16s ease-out; }
.dialog-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--tac-line); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--tac-line); }
@keyframes tac-appear { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Сповіщення ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; font-size: 14px;
  background: var(--tac-panel-2); border: 1px solid var(--tac-line-hi); border-left: 3px solid var(--tac-green);
  border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); animation: tac-appear .16s ease-out; }
.toast.warn { border-left-color: var(--tac-yellow); }
.toast.error { border-left-color: var(--tac-red); }

/* ---------- Друк рапорту ---------- */
.print-only { display: none; }

@media print {
  @page { size: A4 portrait; margin: 16mm 14mm; }
  html, body { background: #fff !important; color: #000 !important; }
  header, main, footer, dialog, .toasts { display: none !important; }
  .print-only { display: block !important; font-family: "Times New Roman", Times, serif; font-size: 13pt; color: #000; }
  .print-only h1 { text-align: center; font-size: 15pt; font-weight: 700; letter-spacing: 0.2em; margin: 10mm 0 4mm; }
  .print-only .addressee { margin-left: 50%; margin-bottom: 6mm; }
  .print-only p { margin: 0 0 3mm; text-align: justify; text-indent: 1.25cm; }
  .print-only table { width: 100%; border-collapse: collapse; font-size: 10.5pt; margin: 4mm 0 8mm; }
  .print-only th, .print-only td { border: 1px solid #000; padding: 3px 5px; text-align: left; vertical-align: top; }
  .print-only th { font-weight: 700; }
  .print-only .sign { display: flex; justify-content: space-between; margin-top: 10mm; }
}

@media (prefers-reduced-motion: reduce) {
  .status.pulse .dot::after, .status.tone-red.pulse, .tac-dialog[open], .toast { animation: none; }
}
