/* easyfakt UI theme on top of Bootstrap 3 */
:root {
    --navy: #2f2d5c;
    --navy-2: #26244d;
    --navy-3: #3b3970;
    --teal: #3a9cc4;
    --teal-2: #2f86a9;
    --teal-soft: #e6f4fa;
    --bg: #f4f6fa;
    --surface: #ffffff;
    --border: #e3e7ef;
    --border-2: #d3d9e4;
    --text: #1d2433;
    --muted: #6b7385;
    --success: #1f9d6b;
    --success-soft: #e3f6ee;
    --danger: #d64545;
    --danger-soft: #fdecec;
    --warning: #c58a12;
    --warning-soft: #fdf3dd;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 1px 3px rgba(20, 24, 40, .06);
    --sidebar-w: 248px;
}

html { -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--teal-2); }
a:hover, a:focus { color: var(--navy); text-decoration: none; }
h1, h2, h3, h4, h5 { font-family: inherit; color: var(--text); font-weight: 600; letter-spacing: -.01em; }
.text-muted { color: var(--muted); }
.ti { font-size: 1.15em; vertical-align: -0.15em; line-height: 1; }
hr { border-color: var(--border); }

/* ---------- Sidebar layout ---------- */
.sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 1030;
    width: var(--sidebar-w);
    background: var(--navy);
    color: #c9cbe3;
    display: flex; flex-direction: column;
}
.sidebar-brand { display: block; padding: 22px 22px 18px; }
.sidebar-brand img { height: 30px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 12px 16px; }
.nav-section {
    margin: 18px 10px 6px;
    font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
    color: #8c8fb8;
}
.sidebar .nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; margin: 1px 0;
    border-radius: var(--radius-sm);
    color: #d6d8ee; font-weight: 500;
    transition: background .12s, color .12s;
}
.sidebar .nav-link .ti { font-size: 19px; color: #9fa2cc; }
.sidebar .nav-link:hover { background: var(--navy-3); color: #fff; }
.sidebar .nav-link.active { background: rgba(127, 208, 240, .14); color: #fff; }
.sidebar .nav-link.active .ti { color: #7fd0f0; }
.sidebar-user { border-top: 1px solid rgba(255, 255, 255, .08); padding: 12px; }
.user-toggle {
    display: flex; align-items: center; gap: 10px;
    padding: 8px; border-radius: var(--radius-sm); color: #fff;
}
.user-toggle:hover, .user-toggle:focus { background: var(--navy-3); color: #fff; }
.user-toggle > .ti { margin-left: auto; color: #8c8fb8; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: #7fd0f0; color: var(--navy);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px; flex: none;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 12px; color: #9fa2cc; }
.sidebar-user .dropdown-menu { left: 12px; right: 12px; bottom: 100%; margin-bottom: 6px; }
.dropdown-btn { display: block; width: 100%; text-align: left; padding: 6px 16px; color: #333; border: 0; }
.dropdown-btn:hover { background: #f5f5f5; text-decoration: none; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.content { padding: 28px 32px 48px; }
.topbar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 1029; background: rgba(20, 24, 40, .4); }
    .main { margin-left: 0; }
    .topbar {
        display: flex; align-items: center; gap: 12px;
        position: sticky; top: 0; z-index: 1020;
        height: 56px; padding: 0 16px;
        background: var(--surface); border-bottom: 1px solid var(--border);
    }
    .topbar-toggle { border: 0; background: none; font-size: 22px; padding: 4px; color: var(--navy); }
    .content { padding: 20px 16px 40px; }
}

/* ---------- Page header ---------- */
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px 16px;
    margin-bottom: 22px;
}
.page-head h1 { font-size: 24px; margin: 0; line-height: 1.25; }
.page-head .page-sub { margin: 4px 0 0; color: var(--muted); }
.page-head .back {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 13px; color: var(--muted); margin-bottom: 6px;
}
.page-head .back:hover { color: var(--navy); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { font-size: 15px; margin: 0; }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); background: #fafbfd; border-radius: 0 0 var(--radius) var(--radius); }
.card > .table-responsive, .card > .table { margin: 0; border: 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font-weight: 500; font-size: 14px;
    border-radius: var(--radius-sm);
    padding: 8px 14px; line-height: 20px;
    border: 1px solid transparent;
    box-shadow: none !important;
    transition: background .12s, border-color .12s, color .12s;
}
.btn .ti { font-size: 17px; }
.btn-lg { padding: 11px 18px; font-size: 15px; }
.btn-sm, .btn-xs { padding: 5px 10px; font-size: 13px; }
.btn-block { display: flex; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active { background: var(--navy-3); border-color: var(--navy-3); color: #fff; }
.btn-success { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-success:hover, .btn-success:focus, .btn-success:active { background: var(--teal-2); border-color: var(--teal-2); color: #fff; }
.btn-default { background: var(--surface); border-color: var(--border-2); color: var(--text); }
.btn-default:hover, .btn-default:focus, .btn-default:active { background: #f3f5f9; border-color: var(--border-2); color: var(--text); }
.btn-danger { background: var(--surface); border-color: #f0c5c5; color: var(--danger); }
.btn-danger:hover, .btn-danger:focus, .btn-danger:active { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-link { color: var(--teal-2); }
.btn:focus, .btn:active:focus { outline: 2px solid rgba(58, 156, 196, .35); outline-offset: 1px; }

/* ---------- Forms ---------- */
label, .control-label { font-weight: 500; font-size: 13px; color: #3c4456; margin-bottom: 6px; }
.form-control {
    height: 40px; padding: 9px 12px;
    font-size: 14px; color: var(--text);
    border: 1px solid var(--border-2); border-radius: var(--radius-sm);
    box-shadow: none;
    transition: border-color .12s, box-shadow .12s;
}
textarea.form-control { height: auto; }
.form-control:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(58, 156, 196, .18); }
.form-control[disabled], .form-control[readonly] { background: #f6f7fa; }
.form-group { margin-bottom: 18px; }
.help-block { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.has-error .form-control { border-color: var(--danger); }
.has-error .form-control:focus { box-shadow: 0 0 0 3px rgba(214, 69, 69, .15); }
.has-error .help-block, .has-error .control-label { color: var(--danger); }
.has-success .form-control { border-color: var(--border-2); }
.has-success .control-label { color: #3c4456; }
.checkbox label, .radio label { font-weight: 400; color: var(--text); font-size: 14px; }
input[type=checkbox], input[type=radio] { accent-color: var(--navy); }
.input-group-addon { background: #f6f7fa; border-color: var(--border-2); color: var(--muted); }
.input-group .form-control:first-child, .input-group-addon:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .form-control:last-child, .input-group-addon:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.form-section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 6px 0 14px; }

/* Select2 (krajee theme) */
.select2-container--krajee .select2-selection { border-color: var(--border-2); border-radius: var(--radius-sm); box-shadow: none; }
.select2-container--krajee .select2-selection--single { height: 40px; padding: 9px 24px 9px 12px; }
.select2-container--krajee.select2-container--focus .select2-selection,
.select2-container--krajee.select2-container--open .select2-selection { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(58, 156, 196, .18); }
.select2-container--krajee .select2-selection--single .select2-selection__arrow { height: 38px; border-left: 0; background: none; }
.select2-container--krajee .select2-dropdown { border-color: var(--border-2); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(20, 24, 40, .12); }
.select2-container--krajee .select2-results__option--highlighted[aria-selected] { background: var(--teal-soft); color: var(--navy); }
.select2-container--krajee .select2-results__option[aria-selected=true] { background: #f1f3f8; color: var(--text); }
.select2-container--krajee .select2-search--dropdown .select2-search__field { border-radius: var(--radius-sm); border-color: var(--border-2); }

/* TinyMCE */
.tox-tinymce { border-color: var(--border-2) !important; border-radius: var(--radius-sm) !important; }

/* ---------- Tables ---------- */
.table { margin-bottom: 0; }
.table > thead > tr > th {
    background: #f8f9fc;
    border-bottom: 1px solid var(--border);
    font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    color: var(--muted);
    padding: 11px 14px; white-space: nowrap;
}
.table > thead > tr > th a { color: var(--muted); }
.table > thead > tr > th a:hover, .table > thead > tr > th a.asc, .table > thead > tr > th a.desc { color: var(--navy); }
.table > thead > tr > th a.asc:after, .table > thead > tr > th a.desc:after { font-family: 'tabler-icons'; margin-left: 4px; }
.table > thead > tr > th a.asc:after { content: "\ea62"; }
.table > thead > tr > th a.desc:after { content: "\ea5f"; }
.table > tbody > tr > td { padding: 11px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
.table > thead > tr.filters > td { padding: 8px 14px; background: #fff; border-bottom: 1px solid var(--border); }
.table > thead > tr.filters .form-control { height: 34px; padding: 6px 10px; font-size: 13px; }
.table-hover > tbody > tr:hover { background: #f7f9fc; }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { padding: 10px 14px; border-top: 1px solid var(--border); }
.grid-view { overflow: hidden; }
.grid-view .table-responsive { margin: 0; border: 0; }
.grid-foot {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
    padding: 12px 16px; border-top: 1px solid var(--border);
}
.grid-foot .summary { color: var(--muted); font-size: 13px; }
.grid-view .empty { display: block; padding: 32px; text-align: center; color: var(--muted); }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }
td.col-actions a {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 7px;
    color: var(--muted); font-size: 17px;
}
td.col-actions a:hover { background: #eef1f6; color: var(--navy); }
td.col-actions a[title="Delete"]:hover, td.col-actions a.danger:hover { background: var(--danger-soft); color: var(--danger); }
tr[data-href] { cursor: pointer; }

/* Pagination */
.pagination { margin: 0; display: flex; gap: 4px; }
.pagination > li > a, .pagination > li > span {
    border: 1px solid transparent; border-radius: 7px !important;
    color: var(--text); padding: 5px 10px; min-width: 32px; text-align: center; font-size: 13px;
}
.pagination > li > a:hover { background: #eef1f6; border-color: transparent; color: var(--navy); }
.pagination > .active > a, .pagination > .active > a:hover, .pagination > .active > span { background: var(--navy); border-color: var(--navy); color: #fff; }
.pagination > .disabled > span, .pagination > .disabled > a { color: #b4bac7; background: none; border-color: transparent; }

/* Detail view */
.detail-view { margin: 0; }
.detail-view > tbody > tr > th { width: 32%; font-weight: 500; color: var(--muted); border-top: 1px solid var(--border); padding: 12px 20px; }
.detail-view > tbody > tr > td { border-top: 1px solid var(--border); padding: 12px 20px; }
.detail-view > tbody > tr:first-child > th, .detail-view > tbody > tr:first-child > td { border-top: 0; }

/* ---------- Badges, alerts ---------- */
.badge-status {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; line-height: 18px;
    background: #eef1f6; color: #4a5367;
}
.badge-status:before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-status.s-nova { background: var(--teal-soft); color: var(--teal-2); }
.badge-status.s-poslana { background: var(--warning-soft); color: var(--warning); }
.badge-status.s-placena { background: var(--success-soft); color: var(--success); }
.badge-muted { background: #eef1f6; color: var(--muted); }
.alert { border-radius: var(--radius); border: 1px solid transparent; padding: 12px 16px; }
.alert-success { background: var(--success-soft); border-color: #bfe7d6; color: #146b49; }
.alert-danger, .alert-error { background: var(--danger-soft); border-color: #f4caca; color: #a12f2f; }
.alert-info { background: var(--teal-soft); border-color: #c4e5f2; color: #1f6b8a; }
.alert-warning { background: var(--warning-soft); border-color: #f2dfb2; color: #8a5f08; }

/* ---------- Invoice page ---------- */
.invoice-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 1199px) { .invoice-grid { grid-template-columns: 1fr; } }
.add-line { display: grid; grid-template-columns: minmax(0, 1fr) 130px auto; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); background: #fafbfd; }
@media (max-width: 600px) { .add-line { grid-template-columns: 1fr 1fr; } .add-line > :first-child { grid-column: 1 / -1; } }
.add-line .form-group { margin: 0; }
.totals { width: 100%; max-width: 360px; margin-left: auto; }
.totals td { padding: 6px 0; }
.totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.totals tr.grand td { padding-top: 12px; border-top: 1px solid var(--border); font-size: 17px; font-weight: 600; color: var(--navy); }
.stat { font-size: 13px; color: var(--muted); }
.stat strong { display: block; font-size: 22px; color: var(--navy); font-weight: 600; letter-spacing: -.01em; }
.collapse-toggle { cursor: pointer; user-select: none; }
.collapse-toggle .ti-chevron-down { transition: transform .15s; }
.collapse-toggle.collapsed .ti-chevron-down { transform: rotate(-90deg); }

/* ---------- Empty / error state ---------- */
.empty-state { max-width: 460px; margin: 60px auto; text-align: center; }
.empty-state > .ti { font-size: 44px; color: var(--teal); }
.empty-state h1 { font-size: 22px; margin: 14px 0 8px; }
.empty-state p { color: var(--muted); margin-bottom: 20px; }

/* ---------- Auth (login) ---------- */
body.auth { background: var(--surface); }
.auth-wrap { display: grid; grid-template-columns: minmax(360px, 44%) 1fr; min-height: 100vh; }
.auth-brand {
    position: relative; overflow: hidden;
    background: var(--navy); color: #c9cbe3;
    padding: 48px 56px; display: flex; flex-direction: column;
}
.auth-brand:after {
    content: ""; position: absolute; right: -120px; bottom: -120px;
    width: 420px; height: 420px; border-radius: 96px; transform: rotate(18deg);
    background: rgba(127, 208, 240, .08);
}
.auth-logo { height: 34px; align-self: flex-start; }
.auth-claim { margin-top: auto; margin-bottom: auto; max-width: 380px; position: relative; z-index: 1; }
.auth-claim h2 { color: #fff; font-size: 34px; line-height: 1.15; margin: 0 0 14px; }
.auth-claim p { font-size: 16px; color: #b9bce0; }
.auth-foot { font-size: 13px; color: #8c8fb8; position: relative; z-index: 1; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 26px; margin: 0 0 6px; }
.auth-card > p { margin-bottom: 26px; }
.auth-card-logo { display: none; height: 30px; margin-bottom: 28px; }
@media (max-width: 767px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .auth-card-logo { display: block; }
}

/* Colour fields (memorandum): swatch + hex without "#" as stored in the database */
.color-field { display: flex; gap: 8px; align-items: center; }
.color-swatch { width: 40px; height: 40px; padding: 3px; border: 1px solid var(--border-2); border-radius: var(--radius-sm); background: #fff; cursor: pointer; flex: none; }
.color-field .form-control { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: lowercase; }
.add-line .select2-container, .form-group .select2-container { width: 100% !important; }

/* ---------- Balance ---------- */
.saldo-dug { color: var(--danger); font-weight: 600; }
.saldo-preplata { color: var(--success); font-weight: 600; }
.saldo-nula { color: var(--muted); }
.saldo-dug small, .saldo-preplata small { font-weight: 500; opacity: .8; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
@media (max-width: 991px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat-grid .card { margin: 0; }
.stat-card { padding: 16px 18px; }
.stat-card span { display: block; font-size: 13px; color: var(--muted); }
.stat-card strong { display: block; margin-top: 4px; font-size: 22px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat-main { border-width: 1px; }
.stat-main.is-dug { background: var(--danger-soft); border-color: #f4caca; }
.stat-main.is-dug strong { color: var(--danger); }
.stat-main.is-preplata { background: var(--success-soft); border-color: #bfe7d6; }
.stat-main.is-preplata strong { color: var(--success); }
.filter-bar .card-body { padding-bottom: 4px; }
.filter-bar .row > div { margin-bottom: 14px; }
.filter-actions { display: flex; gap: 8px; align-items: flex-end; padding-top: 25px; }
@media (max-width: 991px) { .filter-actions { padding-top: 0; } }
