/* =====================================================
   Nova et Vetera — styl aplikace
   Vychází z firemního webu: černobílý minimalismus,
   sans-serif, hodně prostoru, čistá mřížka.
   Efekty jsou tlumené a rychlé — je to nástroj na denní
   práci, animace nesmí zdržovat.
   ===================================================== */

:root {
    /* Neutrální škála — páteř celého vzhledu */
    --n-0:   #ffffff;
    --n-25:  #fcfcfd;
    --n-50:  #f7f8f9;
    --n-100: #eff1f3;
    --n-150: #e4e7ea;
    --n-200: #d8dce0;
    --n-300: #b9c0c7;
    --n-400: #8b949e;
    --n-500: #6b747d;
    --n-600: #4d545c;
    --n-700: #33383e;
    --n-800: #1e2226;
    --n-900: #0a0c0e;

    /* Funkční barvy — nesou význam, proto zůstávají barevné */
    --ok:     #0f7a52;
    --ok-bg:  #e7f4ee;
    --warn:   #9a6206;
    --warn-bg:#fdf3e2;
    --err:    #b42318;
    --err-bg: #fdeceb;
    --info:   #1f5fa8;
    --info-bg:#e9f1fb;

    /* Akcent — teplý tón z jejich fotografií, používaný střídmě */
    --akcent: #b98a3e;

    --r-sm: 6px;
    --r:    10px;
    --r-lg: 14px;

    --stin-1: 0 1px 2px rgba(10, 12, 14, .05);
    --stin-2: 0 2px 4px rgba(10, 12, 14, .06), 0 1px 2px rgba(10, 12, 14, .04);
    --stin-3: 0 8px 20px rgba(10, 12, 14, .09), 0 2px 6px rgba(10, 12, 14, .05);

    --prechod: 140ms cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--n-800);
    background: var(--n-100);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--n-900); text-decoration: none; transition: color var(--prechod); }
a:hover { color: var(--akcent); }

h1, h2, h3 { margin: 0 0 .75rem; line-height: 1.25; letter-spacing: -.015em; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: .95rem; letter-spacing: 0; text-transform: uppercase; color: var(--n-500);
     font-weight: 600; font-size: .78rem; letter-spacing: .07em; }

hr { border: none; border-top: 1px solid var(--n-150); }

.icon { flex: none; vertical-align: -.2em; }
.text-muted { color: var(--n-500); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Viditelný fokus jen při ovládání klávesnicí */
:focus-visible {
    outline: 2px solid var(--n-900);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 252px;
    flex: none;
    background: var(--n-900);
    color: var(--n-300);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    display: flex; align-items: center; gap: .7rem;
    padding: 1.15rem 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    background: var(--n-0); color: var(--n-900);
    border-radius: var(--r-sm);
    font-weight: 700; font-size: .78rem; letter-spacing: -.02em;
    transition: transform var(--prechod);
}
.brand:hover .brand-mark { transform: rotate(-4deg) scale(1.04); }
.brand-text { color: var(--n-0); font-weight: 600; font-size: .95rem; letter-spacing: -.01em; }

.nav { padding: .5rem 0 1.5rem; overflow-y: auto; flex: 1; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 3px; }

.nav-group {
    padding: 1rem 1.15rem .35rem;
    font-size: .66rem; text-transform: uppercase; letter-spacing: .1em;
    color: var(--n-500); font-weight: 600;
}
.nav-item {
    position: relative;
    display: flex; align-items: center; gap: .65rem;
    padding: .5rem 1.15rem;
    color: var(--n-300); font-size: .88rem;
    transition: color var(--prechod), background var(--prechod);
}
/* Proužek vlevo vyjíždí při přejetí — místo skokové změny pozadí */
.nav-item::before {
    content: '';
    position: absolute; left: 0; top: 50%;
    width: 3px; height: 0;
    background: var(--akcent);
    border-radius: 0 2px 2px 0;
    transform: translateY(-50%);
    transition: height var(--prechod);
}
.nav-item:hover { background: rgba(255, 255, 255, .045); color: var(--n-0); text-decoration: none; }
.nav-item:hover::before { height: 45%; }
.nav-item.is-active { background: rgba(255, 255, 255, .08); color: var(--n-0); font-weight: 550; }
.nav-item.is-active::before { height: 62%; }
.nav-item span:first-of-type { flex: 1; }
.nav-item .icon { opacity: .75; transition: opacity var(--prechod); }
.nav-item:hover .icon, .nav-item.is-active .icon { opacity: 1; }
.nav-sub { padding-left: 2.1rem; font-size: .84rem; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .85rem 1.6rem;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--n-150);
    position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 650; font-size: 1.05rem; letter-spacing: -.015em; }
.topbar-user { display: flex; align-items: center; gap: .75rem; font-size: .87rem; }
.user-name { color: var(--n-600); }

.content { flex: 1; padding: 1.6rem; animation: vstup 220ms ease-out; }
@keyframes vstup { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.footer {
    padding: 1rem 1.6rem;
    color: var(--n-400); font-size: .78rem;
    border-top: 1px solid var(--n-150);
    display: flex; align-items: center; gap: .5rem;
}

body.centered {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 1.5rem;
    background: var(--n-900);
    background-image:
        radial-gradient(circle at 18% 22%, rgba(185, 138, 62, .16), transparent 46%),
        radial-gradient(circle at 82% 78%, rgba(255, 255, 255, .07), transparent 52%);
}

/* ---------- Karty ---------- */
.card {
    background: var(--n-0);
    border: 1px solid var(--n-150);
    border-radius: var(--r);
    box-shadow: var(--stin-1);
    margin-bottom: 1.25rem;
    transition: box-shadow var(--prechod), border-color var(--prechod);
}
.card:hover { box-shadow: var(--stin-2); }
.card-narrow {
    width: 100%; max-width: 430px; margin: 0;
    box-shadow: var(--stin-3);
    animation: vstup 300ms ease-out;
}
.card-header {
    padding: .85rem 1.15rem;
    border-bottom: 1px solid var(--n-150);
    font-weight: 620; font-size: .93rem;
    display: flex; align-items: center; justify-content: space-between; gap: .6rem;
    letter-spacing: -.01em;
}
.card-body { padding: 1.15rem; }

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* ---------- KPI dlaždice ---------- */
.stat {
    position: relative;
    background: var(--n-0);
    border: 1px solid var(--n-150);
    border-radius: var(--r);
    padding: 1.05rem 1.15rem;
    box-shadow: var(--stin-1);
    overflow: hidden;
    transition: transform var(--prechod), box-shadow var(--prechod);
}
/* Tenká linka nahoře se rozjede po celé šířce při přejetí */
.stat::after {
    content: '';
    position: absolute; top: 0; left: 0;
    height: 2px; width: 0;
    background: linear-gradient(90deg, var(--akcent), var(--n-900));
    transition: width 280ms cubic-bezier(.4, 0, .2, 1);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--stin-3); }
.stat:hover::after { width: 100%; }
.stat-label { font-size: .72rem; color: var(--n-500); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 680; margin-top: .35rem; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-value.neg { color: var(--err); }
.stat-sub { font-size: .78rem; color: var(--n-400); margin-top: .2rem; }

/* ---------- Tabulky ---------- */
.table-wrap { overflow-x: auto; }
.table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--n-200); border-radius: 4px; }

table.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.table th, table.table td { padding: .62rem .8rem; text-align: left; border-bottom: 1px solid var(--n-100); }
table.table th {
    font-size: .69rem; text-transform: uppercase; letter-spacing: .08em;
    color: var(--n-500); font-weight: 650; white-space: nowrap;
    background: var(--n-25);
}
table.table td { font-variant-numeric: tabular-nums; }
table.table tbody tr { transition: background var(--prechod); }
table.table tbody tr:hover { background: var(--n-25); }
table.table tbody tr:last-child td { border-bottom: none; }
/* Odkaz v tabulce podtrhává až při přejetí řádku */
table.table tbody tr a { position: relative; font-weight: 550; }
table.table tbody tr:hover a { color: var(--akcent); }

.empty { padding: 2.8rem 1rem; text-align: center; color: var(--n-400); font-size: .9rem; }

/* ---------- Odznaky ---------- */
.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .715rem; font-weight: 620; white-space: nowrap;
    letter-spacing: .01em;
    border: 1px solid transparent;
}
.badge-gold  { background: #fbf1de; color: #7a5410; border-color: #f0dcb8; }
.badge-amber { background: var(--warn-bg); color: var(--warn); border-color: #f5e2c0; }
.badge-blue  { background: var(--info-bg); color: var(--info); border-color: #cfe0f5; }
.badge-green { background: var(--ok-bg); color: var(--ok); border-color: #c7e6d7; }
.badge-red   { background: var(--err-bg); color: var(--err); border-color: #f7d2ce; }
.badge-slate { background: var(--n-100); color: var(--n-700); border-color: var(--n-150); }
.badge-gray  { background: var(--n-50); color: var(--n-500); border-color: var(--n-150); }

/* ---------- Tlačítka ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .42rem;
    padding: .52rem .95rem;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    font-size: .87rem; font-weight: 600; font-family: inherit;
    cursor: pointer;
    background: var(--n-100); color: var(--n-700);
    transition: background var(--prechod), color var(--prechod),
                border-color var(--prechod), box-shadow var(--prechod), transform 90ms ease;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--n-900); color: var(--n-0); box-shadow: var(--stin-1); }
.btn-primary:hover { background: var(--n-800); color: var(--n-0); box-shadow: var(--stin-2); }

.btn-secondary { background: var(--n-0); color: var(--n-700); border-color: var(--n-200); }
.btn-secondary:hover { background: var(--n-50); border-color: var(--n-300); color: var(--n-900); }

.btn-danger { background: var(--err); color: var(--n-0); }
.btn-danger:hover { background: #9c1e14; color: var(--n-0); }

.btn-ghost { background: transparent; color: var(--n-500); }
.btn-ghost:hover { background: var(--n-100); color: var(--n-900); }

.btn-sm   { padding: .32rem .62rem; font-size: .79rem; }
.btn-icon { padding: .36rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.actions { display: flex; gap: .55rem; align-items: center; flex-wrap: wrap; }
.page-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.15rem; flex-wrap: wrap;
}

/* ---------- Formuláře ---------- */
.form-row { margin-bottom: .9rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
label.form-label {
    display: block; font-size: .78rem; font-weight: 620; color: var(--n-600);
    margin-bottom: .3rem; letter-spacing: .01em;
}
.form-control {
    width: 100%;
    padding: .52rem .68rem;
    border: 1px solid var(--n-200);
    border-radius: var(--r-sm);
    font-size: .89rem; font-family: inherit;
    background: var(--n-0); color: var(--n-900);
    transition: border-color var(--prechod), box-shadow var(--prechod), background var(--prechod);
}
.form-control:hover { border-color: var(--n-300); }
.form-control:focus {
    outline: none;
    border-color: var(--n-900);
    box-shadow: 0 0 0 3px rgba(10, 12, 14, .07);
}
textarea.form-control { min-height: 92px; resize: vertical; }
select.form-control { cursor: pointer; }
.form-hint { font-size: .77rem; color: var(--n-400); margin: .32rem 0 0; line-height: 1.45; }

input[type="checkbox"] { accent-color: var(--n-900); width: 15px; height: 15px; cursor: pointer; }
input[type="file"].form-control { padding: .35rem; cursor: pointer; }

/* ---------- Hlášky ---------- */
.alert {
    padding: .72rem .95rem;
    border-radius: var(--r-sm);
    margin-bottom: 1rem; font-size: .87rem;
    border: 1px solid transparent; border-left-width: 3px;
    animation: vstup 220ms ease-out;
}
.alert-success { background: var(--ok-bg);   color: var(--ok);   border-color: #c7e6d7; border-left-color: var(--ok); }
.alert-error   { background: var(--err-bg);  color: var(--err);  border-color: #f7d2ce; border-left-color: var(--err); }
.alert-info    { background: var(--info-bg); color: var(--info); border-color: #cfe0f5; border-left-color: var(--info); }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: #f5e2c0; border-left-color: var(--warn); }

/* ---------- Karta nemovitosti: záhlaví + záložky ---------- */
.prop-head {
    background: var(--n-0);
    border: 1px solid var(--n-150);
    border-radius: var(--r) var(--r) 0 0;
    padding: 1.3rem 1.35rem 1rem;
}
.prop-id {
    font-size: .74rem; color: var(--n-400); letter-spacing: .1em;
    font-weight: 650; text-transform: uppercase;
}
.prop-adresa { font-size: 1.45rem; font-weight: 680; margin: .25rem 0 .5rem; letter-spacing: -.025em; }
.prop-meta { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .85rem; color: var(--n-600); }
.prop-meta span { position: relative; }
.prop-meta span + span::before {
    content: '';
    position: absolute; left: -.55rem; top: 50%;
    width: 3px; height: 3px; margin-top: -1.5px;
    background: var(--n-300); border-radius: 50%;
}
.prop-osoby {
    display: flex; flex-wrap: wrap; gap: .4rem 1.4rem;
    margin-top: .85rem; padding-top: .8rem;
    border-top: 1px solid var(--n-100);
    font-size: .81rem; color: var(--n-500);
}
.prop-osoby strong { color: var(--n-700); font-weight: 620; }

.tabs {
    display: flex; gap: .1rem;
    background: var(--n-0);
    border: 1px solid var(--n-150); border-top: none;
    padding: 0 1.35rem;
    overflow-x: auto;
}
.tab {
    position: relative;
    padding: .7rem 1rem;
    font-size: .87rem; font-weight: 620;
    color: var(--n-400);
    display: flex; align-items: center; gap: .4rem;
    white-space: nowrap;
    transition: color var(--prechod);
}
/* Podtržení vyjíždí ze středu */
.tab::after {
    content: '';
    position: absolute; bottom: -1px; left: 50%; right: 50%;
    height: 2px; background: var(--n-900);
    transition: left var(--prechod), right var(--prechod);
}
.tab:hover { color: var(--n-900); text-decoration: none; }
.tab:hover::after { left: 20%; right: 20%; }
.tab.is-active { color: var(--n-900); }
.tab.is-active::after { left: 0; right: 0; background: var(--akcent); }
.tab.is-done { color: var(--ok); }
.tab.is-done:hover::after { background: var(--ok); }
.tab.is-locked { color: var(--n-300); cursor: not-allowed; }
.tab.is-locked:hover::after { left: 50%; right: 50%; }

.tab-panel {
    background: var(--n-0);
    border: 1px solid var(--n-150); border-top: none;
    border-radius: 0 0 var(--r) var(--r);
    padding: 1.35rem;
    margin-bottom: 1.25rem;
    animation: vstup 200ms ease-out;
}

/* ---------- Business case ---------- */
.bc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .85rem; }
.bc-item {
    padding: .8rem .9rem;
    background: var(--n-25);
    border: 1px solid var(--n-100);
    border-radius: var(--r-sm);
    transition: background var(--prechod), border-color var(--prechod), transform var(--prechod);
}
.bc-item:hover { background: var(--n-0); border-color: var(--n-200); transform: translateY(-1px); }
.bc-label { font-size: .69rem; color: var(--n-500); text-transform: uppercase; letter-spacing: .08em; font-weight: 620; }
.bc-value {
    font-size: 1.15rem; font-weight: 680; margin-top: .25rem;
    letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.bc-value.pos { color: var(--ok); }
.bc-value.neg { color: var(--err); }

/* ---------- Milníky ---------- */
/* Pořadové číslo se barví podle stavu. Stavová třída sedí přímo na tomhle
   prvku — milníky se vykreslují jako řádky tabulky, ne jako samostatné bloky. */
.milnik-poradi {
    flex: none; width: 27px; height: 27px; border-radius: 50%;
    background: var(--n-100); color: var(--n-500);
    display: flex; align-items: center; justify-content: center;
    font-size: .74rem; font-weight: 680;
    transition: background var(--prechod), color var(--prechod);
}
.milnik-poradi.splnen     { background: var(--ok-bg);   color: var(--ok); }
.milnik-poradi.v_plneni   { background: var(--warn-bg); color: var(--warn); }
.milnik-poradi.po_terminu { background: var(--err-bg);  color: var(--err); }

/* ---------- Ganttův diagram ---------- */
.gantt-radek {
    display: flex; align-items: center; gap: .8rem;
    padding: .28rem 0;
    border-radius: var(--r-sm);
    transition: background var(--prechod);
}
.gantt-radek:hover { background: var(--n-25); }
.gantt-nazev {
    flex: none; width: 215px;
    font-size: .79rem; color: var(--n-600);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gantt-osa {
    position: relative; flex: 1; height: 18px;
    background: linear-gradient(90deg, var(--n-100), var(--n-50));
    border-radius: 9px;
}
.gantt-bod {
    position: absolute; top: 50%;
    width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px;
    border-radius: 50%; border: 2px solid var(--n-0);
    box-shadow: var(--stin-1);
    transition: transform var(--prechod);
    cursor: help;
}
.gantt-bod:hover { transform: scale(1.45); z-index: 2; }
.gantt-plan  { background: var(--n-400); }
.gantt-skut  { background: var(--ok); }
.gantt-pozde { background: var(--err); }

/* ---------- Přihlášení ---------- */
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand .brand-mark {
    width: 50px; height: 50px; font-size: 1rem;
    margin: 0 auto .7rem;
    background: var(--n-900); color: var(--n-0);
}
.login-brand h1 { font-size: 1.25rem; margin: 0; letter-spacing: -.02em; }
.err-code { font-size: 3.2rem; margin: 0 0 .3rem; color: var(--n-200); font-weight: 700; letter-spacing: -.04em; }

/* ---------- Responsivita ---------- */
@media (max-width: 880px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; position: static; height: auto; }
    .nav { display: flex; flex-wrap: wrap; gap: .2rem; padding: .45rem; }
    .nav-group { display: none; }
    .nav-item { border-radius: var(--r-sm); padding: .4rem .65rem; }
    .nav-item::before { display: none; }
    .nav-sub { padding-left: .65rem; }
    .content { padding: 1rem; }
    .topbar { padding: .7rem 1rem; }
    .prop-adresa { font-size: 1.2rem; }
    .gantt-nazev { width: 125px; }
}

/* Kdo si vypnul animace, ten je nedostane */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ---------- Tisk ---------- */
@media print {
    .sidebar, .topbar, .footer, .actions, .btn, form.card { display: none !important; }
    .content { padding: 0; }
    .card, .tab-panel, .prop-head { border: 1px solid #ccc; box-shadow: none; }
    body { background: #fff; }
}
