/* AveLog - profesionalne rozhranie technickeho dennika */
:root {
  --navy-900: #0b1b2b;
  --navy-800: #0f2437;
  --navy-700: #143352;
  --navy-600: #1c4a75;
  --accent: #2f80ed;
  --accent-dark: #1c66c9;
  --ok: #17915a;
  --ok-bg: #e6f6ee;
  --warn: #b7791f;
  --warn-bg: #fdf3e2;
  --danger: #c0392b;
  --danger-bg: #fbeceb;
  --ink: #12212f;
  --muted: #64748b;
  --line: #dbe3ec;
  --bg: #f2f5f9;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,32,48,.06), 0 8px 24px rgba(16,32,48,.06);
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0 0 .4rem; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .6rem; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- prihlasenie ---------- */
.login-wrap {
  min-height: 100%; display: grid; place-items: center; padding: 2rem;
  background: radial-gradient(1200px 600px at 20% -10%, #1d4a75 0%, var(--navy-900) 55%, #060f18 100%);
}
.login-card {
  width: min(420px, 100%); background: var(--card); border-radius: 16px; padding: 2rem;
  box-shadow: 0 24px 60px rgba(3,12,22,.45);
}
.login-card .brand { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.2rem; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--navy-800), var(--navy-900));
  color: #cfe0f0; padding: 1rem .75rem; display: flex; flex-direction: column; gap: .25rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: #fff; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #6fb1ff); color: #06192c; font-weight: 800;
}
.brand small { display: block; font-weight: 500; color: #8fb3d4; letter-spacing: .04em; text-transform: uppercase; font-size: 10px; }
.nav { margin-top: 1.2rem; display: flex; flex-direction: column; gap: 2px; }
.nav-group { color: #6d8dab; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; margin: 1rem .6rem .3rem; }
.nav a {
  display: flex; align-items: center; gap: .6rem; padding: .5rem .65rem; border-radius: 9px;
  color: #cfe0f0; font-weight: 500; text-decoration: none; font-size: 13.5px;
}
.nav a:hover { background: rgba(255,255,255,.07); }
.nav a.active { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(47,128,237,.35); }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar .foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.08); color: #7f9fbd; font-size: 11.5px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line); padding: .7rem 1.5rem;
  display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: .55rem; padding: .3rem .5rem; border-radius: 999px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--navy-700); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.content { padding: 1.4rem 1.5rem 3rem; max-width: 1500px; width: 100%; }

/* ---------- karty, mriezky ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.card-head { padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .75rem; }
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 1.1rem; }
.card-head .spacer { flex: 1; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid.cols-5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
.grid.cols-6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; margin-top: .2rem; }
.stat .value small { font-size: .85rem; font-weight: 600; color: var(--muted); }

/* ---------- formulare ---------- */
label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .25rem; }
input, select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 9px; background: #fff;
  font: inherit; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,128,237,.15); }
input[readonly] { background: #f6f8fb; color: var(--muted); }
textarea { min-height: 76px; resize: vertical; }
.field { margin-bottom: .8rem; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: .25rem; text-transform: none; letter-spacing: 0; font-weight: 400; }
.checkbox { display: inline-flex; align-items: center; gap: .4rem; font-size: 13px; color: var(--ink); text-transform: none; letter-spacing: 0; font-weight: 500; }
.checkbox input { width: 16px; height: 16px; }

.btn {
  display: inline-flex; align-items: center; gap: .45rem; padding: .5rem .9rem; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600;
  cursor: pointer; transition: .15s; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f6f8fb; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.dark { background: var(--navy-700); border-color: var(--navy-700); color: #fff; }
.btn.dark:hover { background: var(--navy-800); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: #eef2f7; }
.btn.danger { color: var(--danger); border-color: #f0c7c2; background: var(--danger-bg); }
.btn.sm { padding: .3rem .6rem; font-size: 12.5px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- tabulky ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .6rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #f8fafc; font-weight: 700; }
tbody tr:hover { background: #f9fbfd; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .5rem; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; background: #eef2f7; color: var(--muted); white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: #e8f1fd; color: var(--accent-dark); }
.badge.hr { background: #fdeaea; color: #b02a1e; }

/* ---------- techlog editor ---------- */
.techlog-head { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: .8rem; }
.flights { overflow-x: auto; }
.flights table { min-width: 1520px; }
.flights th:nth-child(2), .flights td:nth-child(2) { min-width: 124px; }
.flights th:nth-child(3), .flights td:nth-child(3) { min-width: 112px; }
.flights th:nth-child(4), .flights td:nth-child(4) { min-width: 104px; }
.flights th:nth-child(5), .flights td:nth-child(5) { min-width: 210px; }
.flights th:nth-child(n+6):nth-child(-n+9), .flights td:nth-child(n+6):nth-child(-n+9) { min-width: 92px; }
.flights th:nth-child(10), .flights td:nth-child(10),
.flights th:nth-child(11), .flights td:nth-child(11) { min-width: 116px; }
.flights th:nth-child(12), .flights td:nth-child(12) { min-width: 96px; }
.flights th:nth-child(13), .flights td:nth-child(13) { min-width: 118px; }
.flights th:nth-child(14), .flights td:nth-child(14),
.flights th:nth-child(15), .flights td:nth-child(15) { min-width: 96px; }
.flights th:nth-child(16), .flights td:nth-child(16) { min-width: 190px; }
.flights th { position: sticky; top: 0; z-index: 2; }
.flights td { padding: .35rem .3rem; }
.flights input, .flights select { padding: .38rem .45rem; font-size: 13px; }
.flights td.seq { text-align: center; font-weight: 800; color: var(--navy-600); background: #f8fafc; }
.flights .col-time input { text-align: center; font-family: var(--mono); }
.flights .col-num input { text-align: right; font-family: var(--mono); }
.totals-box { background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.totals-box .line { display: flex; justify-content: space-between; gap: 1rem; padding: .25rem 0; }
.totals-box .line.strong { border-top: 1px solid var(--line); margin-top: .3rem; padding-top: .5rem; font-weight: 800; font-size: 1.05rem; }
.sticky-actions {
  position: sticky; bottom: 0; z-index: 15; background: rgba(255,255,255,.94); backdrop-filter: blur(6px);
  border-top: 1px solid var(--line); padding: .7rem 1.1rem; display: flex; gap: .6rem; align-items: center;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ---------- pomocne ---------- */
.toast-wrap { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast {
  background: var(--navy-800); color: #eaf2fa; padding: .7rem .9rem; border-radius: 10px; box-shadow: 0 10px 30px rgba(8,20,32,.3);
  max-width: 380px; font-size: 13px; animation: slide .2s ease-out;
}
.toast.ok { background: #14663f; } .toast.err { background: #96281b; }
@keyframes slide { from { transform: translateY(8px); opacity: 0 } to { transform: none; opacity: 1 } }

.modal-backdrop { position: fixed; inset: 0; background: rgba(8,18,28,.5); display: grid; place-items: center; z-index: 90; padding: 1rem; }
.modal { background: #fff; border-radius: 14px; width: min(720px, 100%); max-height: 88vh; overflow: auto; box-shadow: 0 30px 70px rgba(3,12,22,.35); }
.modal .card-head { position: sticky; top: 0; background: #fff; z-index: 2; }

.alert { border-radius: 10px; padding: .7rem .9rem; font-size: 13px; margin-bottom: .8rem; border: 1px solid transparent; }
.alert.warn { background: var(--warn-bg); border-color: #f0dcb4; color: #7a5312; }
.alert.err { background: var(--danger-bg); border-color: #f0c7c2; color: #8f2318; }
.alert.ok { background: var(--ok-bg); border-color: #bfe6d3; color: #0f6b43; }
.alert ul { margin: .3rem 0 0; padding-left: 1.1rem; }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .big { font-size: 2rem; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
.loading { display: grid; place-items: center; padding: 3rem; color: var(--muted); }

@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .nav { flex-direction: row; flex-wrap: wrap; margin: 0; }
  .sidebar .nav-group, .sidebar .foot { display: none; }
  .grid.cols-4, .grid.cols-3, .grid.cols-5, .grid.cols-6 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .techlog-head { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media print {
  .sidebar, .topbar, .sticky-actions, .btn { display: none !important; }
  .app { grid-template-columns: 1fr; } body { background: #fff; }
}

/* ---------- vloženie do cudzieho webu (iframe) ---------- */
html.embedded, html.embedded body { background: var(--bg); }
html.embedded .sidebar { height: auto; position: static; }
html.embedded .topbar { position: static; }
html.embedded .content { padding-bottom: 1.5rem; }
html.embedded .login-wrap { min-height: 620px; }
