/* Písmo Nunito podľa dizajn manuálu NATUR-PACK (WEB – text) */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../fonts/nunito-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../fonts/nunito-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* korporátne farby: GREEN Pantone 576 C (RGB 106-140-60), BLACK */
  --brand: #6a8c3c;
  --brand-dark: #4e6a2b;
  --brand-tint: #eef3e6;
  --cream: #f8f5e4;
  --accent: #d95b3a;

  --bg: var(--cream);
  --surface: #ffffff;
  --text: #231f20;
  --muted: #625c55;
  --border: #e4dfcc;
  /* o odtieň tmavšia zelená kvôli čitateľnosti bieleho textu na tlačidlách */
  --primary: #5e7d35;
  --primary-hover: var(--brand-dark);
  --success: #4e7a2b;
  --warning: #9a5c00;
  --danger: #b8402a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(35, 31, 32, 0.05), 0 2px 8px rgba(35, 31, 32, 0.04);
  --font: 'Nunito', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}

h1 { font-size: 1.6rem; font-weight: 800; margin: 0; line-height: 1.25; }
h2 { font-size: 1.15rem; font-weight: 800; margin: 0 0 0.75rem; }
h3 { font-size: 0.8rem; font-weight: 800; margin: 0 0 0.5rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--brand-dark); }

a { color: var(--primary); }
a:hover { color: var(--brand-dark); }

.container { max-width: 1200px; margin: 0 auto; padding: 28px 16px 64px; }

.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.mono { font-family: var(--mono); font-size: 0.9em; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- hlavička ---------- */

/* logo je na bielom pozadí bez rámčeka (ochranná zóna podľa manuálu) */
.app-header {
  background: var(--surface);
  color: var(--text);
  border-bottom: 4px solid var(--brand);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 68px;
  flex-wrap: wrap;
}
.brand {
  color: var(--text);
  font-weight: 800;
  font-size: 1.05rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand:hover { color: var(--text); }
.brand-logo {
  height: 52px;
  width: auto;
  display: block;
}
.main-nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.main-nav a {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 999px;
}
.main-nav a:hover { color: var(--brand-dark); background: var(--brand-tint); }
.main-nav a.active { color: #fff; background: var(--brand); }
.user-box { display: flex; align-items: center; gap: 12px; }
.firma-select {
  font: inherit;
  font-weight: 700;
  padding: 6px 10px;
  border: 1px solid var(--brand);
  border-radius: 999px;
  background: var(--brand-tint);
  color: var(--text);
  max-width: 180px;
}
.user-name { display: flex; flex-direction: column; line-height: 1.2; text-align: right; font-weight: 700; }
.user-name small { color: var(--muted); font-weight: 400; }

/* ---------- tlačidlá a formuláre ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-tint); border-color: #cfdcba; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn[aria-disabled="true"] { pointer-events: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .dropzone:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.btn-small { padding: 4px 12px; font-size: 0.875rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #3d6122; border-color: #3d6122; }
.btn-warning { background: #b86a06; border-color: #b86a06; color: #fff; }
.btn-warning:hover { background: #9a5904; border-color: #9a5904; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #9a3422; border-color: #9a3422; }
.btn-danger-outline { color: var(--danger); border-color: #ecc1b6; }
.btn-danger-outline:hover { background: #fcefea; border-color: #e3a898; }
.btn-link { border-color: transparent; background: transparent; color: var(--primary); padding-left: 4px; padding-right: 4px; }
.btn-link:hover { background: transparent; border-color: transparent; text-decoration: underline; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

input, select, textarea {
  font: inherit;
  color: inherit;
  padding: 7px 12px;
  border: 1px solid #d6d0bb;
  border-radius: 8px;
  background: #fff;
  width: 100%;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { resize: vertical; }
input[type="checkbox"] { width: auto; accent-color: var(--brand); }

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.field-hint { color: var(--muted); font-size: 0.8rem; }
.field-error { color: var(--danger); margin: 0; font-weight: 600; }
.checkbox { display: flex; align-items: center; gap: 8px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .checkbox { grid-column: 1 / -1; }

/* ---------- rozloženie stránky ---------- */

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
/* zelený pruh pri nadpise ako v dizajn manuáli */
.page-head h1 { border-left: 6px solid var(--brand); padding-left: 12px; }
.page-head .meta { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 8px; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 700; }
.back:hover { text-decoration: underline; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; }
.alert-error { background: #fcece6; color: #8a2f1e; border: 1px solid #f0c6b9; }

.empty {
  background: var(--surface);
  border: 1px dashed #d6d0bb;
  border-radius: var(--radius);
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}

/* ---------- odznaky stavov ---------- */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-neutral { background: #ece8da; color: #4f4a43; }
.badge-pending { background: #fdedc8; color: #7a4a00; }
.badge-ok { background: #e1edd2; color: #3d5e1f; }
.badge-note { background: #dcebef; color: #1f5866; }
.badge-rejected { background: #f9e0d8; color: #962f1c; }

/* ---------- tabuľky ---------- */

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 0.8rem; font-weight: 800; color: var(--brand-dark); background: var(--brand-tint); white-space: nowrap; }
.table th.num, .table td.num { text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-clickable tbody tr { cursor: pointer; }
.table-clickable tbody tr:hover { background: #f7faf2; }
.table-clickable a { font-weight: 700; text-decoration: none; }
.table tr.overdue td:nth-child(5) { color: var(--danger); font-weight: 700; }
.overdue-tag {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
}
.table tr.inactive td { color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- filtre ---------- */

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px 16px;
  align-items: end;
}
.filters fieldset { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; min-width: 0; }
.filters legend { font-size: 0.85rem; font-weight: 700; color: var(--muted); padding: 0; margin-bottom: 4px; }
.filters .range { grid-column: span 2; }
.filter-actions { display: flex; justify-content: flex-end; }
.count { margin: 0 0 8px; font-size: 0.875rem; color: var(--muted); }

/* ---------- detail faktúry ---------- */

.actions { display: flex; flex-direction: column; gap: 16px; }
.action-group + .action-group { border-top: 1px solid var(--border); padding-top: 16px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1 1 260px; max-width: 420px; }

.decision { border-left: 5px solid var(--border); }
.decision-ok { border-left-color: var(--brand); }
.decision-note { border-left-color: #2a7f93; }
.decision-rejected { border-left-color: var(--danger); }
.decision-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.decision blockquote { margin: 12px 0 0; padding: 10px 14px; background: var(--cream); border-radius: 8px; white-space: pre-wrap; }

.pdf-preview summary { cursor: pointer; font-weight: 700; }
.pdf-preview iframe { width: 100%; height: 80vh; border: 1px solid var(--border); border-radius: 8px; margin-top: 12px; }

/* ---------- nahrávanie ---------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 40px 16px;
  border: 2px dashed #b9c99f;
  border-radius: var(--radius);
  background: #fbfcf8;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
}
.dropzone strong { color: var(--text); font-size: 1.05rem; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-tint); }
.file-list { list-style: none; padding: 0; margin: 12px 0; }
.file-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.file-list li span { overflow-wrap: anywhere; }
.upload-footer { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.upload-footer .field { flex: 1 1 300px; max-width: 420px; }
.upload-results { margin-top: 24px; }

/* ---------- záložky ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a {
  padding: 8px 14px;
  margin-bottom: -1px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--brand-dark); border-bottom-color: var(--brand); }

/* ---------- ručné zadanie faktúry ---------- */

.manual-form .panel h2 { margin-bottom: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.dept-fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px 12px; margin: 0; min-width: 0; }
.dept-fieldset legend { font-weight: 700; padding: 0 4px; }
.dept-fieldset p { margin: 0 0 8px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.required-mark { color: var(--danger); }
.form-footer { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* ---------- prihlásenie ---------- */

.login-wrap { display: flex; justify-content: center; padding-top: 10vh; }
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 6px solid var(--brand);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-logo { display: block; width: 200px; height: auto; margin: 0 auto; }
.login-card h1 { text-align: center; margin-bottom: 8px; font-size: 1.35rem; }

/* ---------- modálne okná a oznámenia ---------- */

.modal {
  width: min(560px, calc(100vw - 32px));
  border: 0;
  border-top: 5px solid var(--brand);
  border-radius: 14px;
  padding: 24px;
  color: var(--text);
  box-shadow: 0 10px 40px rgba(35, 31, 32, 0.25);
}
.modal::backdrop { background: rgba(35, 31, 32, 0.45); }
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-body p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  max-width: min(420px, calc(100vw - 32px));
}
.toast {
  padding: 10px 16px;
  border-radius: 10px;
  color: #fff;
  font-weight: 600;
  background: var(--text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  animation: toast-in 0.2s ease-out;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- mobil ---------- */

@media (max-width: 640px) {
  .header-inner { gap: 8px 16px; padding-top: 8px; padding-bottom: 8px; }
  .brand-logo { height: 42px; }
  .brand-title { display: none; }
  .main-nav { order: 3; flex-basis: 100%; }
  .user-box { margin-left: auto; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .filters .range { grid-column: auto; }
  .page-head .btn-row { width: 100%; }
}
