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

:root, [data-theme="temna"] {
    --bg:       #0a0f1c;
    --surface:  #1a2438;
    --surface2: #243356;
    --border:   #3c4f74;
    --text:     #f8fafc;
    --text-sec: #aebbd0;
    --text-dim: #7288ab;
    --primary:  #0ea5e9;
    --primary-h:#38bdf8;
    --shadow:       0 10px 28px rgba(0,0,0,.5);
    --shadow-sm:    0 3px 10px rgba(0,0,0,.4);
    --shadow-inset: inset 0 1px 0 rgba(255,255,255,.04);
    --danger:   #ef4444;
    --success:  #22c55e;
    --warning:  #f59e0b;
    --yellow:   #f59e0b;
    --green:    #22c55e;
    --red:      #ef4444;
    --sidebar-w: 280px;
    --header-h:  56px;
    --banner-h:  34px;
    --copy-h:    26px;
}
[data-theme="svetla"] {
    --bg:       #e7ecf3;
    --surface:  #ffffff;
    --surface2: #dde4ee;
    --border:   #b9c4d4;
    --text:     #0f172a;
    --text-sec: #3d4a61;
    --text-dim: #64748b;
    --primary:  #0284c7;
    --primary-h:#0369a1;
    --shadow:       0 10px 25px rgba(30,41,59,.14);
    --shadow-sm:    0 2px 8px rgba(30,41,59,.09);
    --shadow-inset: inset 0 1px 0 rgba(255,255,255,.6);
    --danger:   #dc2626;
    --success:  #16a34a;
    --warning:  #d97706;
    --yellow:   #d97706;
    --green:    #16a34a;
    --red:      #dc2626;
}
[data-theme="zelena"] {
    --bg:       #050e08;
    --surface:  #12331f;
    --surface2: #1a472d;
    --border:   #2f6b45;
    --text:     #ecfdf5;
    --text-sec: #8fe6ac;
    --text-dim: #57c980;
    --primary:  #22c55e;
    --primary-h:#4ade80;
    --shadow:       0 10px 28px rgba(0,0,0,.55);
    --shadow-sm:    0 3px 10px rgba(0,0,0,.4);
    --shadow-inset: inset 0 1px 0 rgba(255,255,255,.04);
    --danger:   #ef4444;
    --success:  #4ade80;
    --warning:  #fbbf24;
    --yellow:   #fbbf24;
    --green:    #4ade80;
    --red:      #ef4444;
}
[data-theme="modra"] {
    --bg:       #020a16;
    --surface:  #0d2340;
    --surface2: #153a5c;
    --border:   #2c5789;
    --text:     #e3edfc;
    --text-sec: #9dc2f5;
    --text-dim: #6ea3e8;
    --primary:  #3b82f6;
    --primary-h:#60a5fa;
    --shadow:       0 10px 28px rgba(0,0,0,.55);
    --shadow-sm:    0 3px 10px rgba(0,0,0,.4);
    --shadow-inset: inset 0 1px 0 rgba(255,255,255,.04);
    --danger:   #ef4444;
    --success:  #22c55e;
    --warning:  #f59e0b;
    --yellow:   #f59e0b;
    --green:    #22c55e;
    --red:      #ef4444;
}
[data-theme="oranzna"] {
    --bg:       #120600;
    --surface:  #301400;
    --surface2: #432000;
    --border:   #6e3a00;
    --text:     #fff7ed;
    --text-sec: #ffcb94;
    --text-dim: #fb923c;
    --primary:  #f97316;
    --primary-h:#fb923c;
    --shadow:       0 10px 28px rgba(0,0,0,.55);
    --shadow-sm:    0 3px 10px rgba(0,0,0,.4);
    --shadow-inset: inset 0 1px 0 rgba(255,255,255,.04);
    --danger:   #ef4444;
    --success:  #22c55e;
    --warning:  #fbbf24;
    --yellow:   #fbbf24;
    --green:    #22c55e;
    --red:      #ef4444;
}
[data-theme="antracitna"] {
    --bg:       #101010;
    --surface:  #212121;
    --surface2: #2f2f2f;
    --border:   #4a4a4a;
    --text:     #f7f7f7;
    --text-sec: #b5b5b5;
    --text-dim: #8a8a8a;
    --primary:  #a78bfa;
    --primary-h:#c4b5fd;
    --shadow:       0 10px 28px rgba(0,0,0,.55);
    --shadow-sm:    0 3px 10px rgba(0,0,0,.4);
    --shadow-inset: inset 0 1px 0 rgba(255,255,255,.04);
    --danger:   #ef4444;
    --success:  #22c55e;
    --warning:  #f59e0b;
    --yellow:   #f59e0b;
    --green:    #22c55e;
    --red:      #ef4444;
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Prijavna stran ── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow), var(--shadow-inset);
}
.login-logo {
    text-align: center;
    margin-bottom: 1.75rem;
}
.login-logo h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
    text-shadow: 0 0 16px color-mix(in srgb, var(--primary) 45%, transparent);
}
.login-logo p {
    color: var(--text-sec);
    font-size: .85rem;
    margin-top: .25rem;
}

/* ── Obrazci ── */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: .82rem;
    color: var(--text-sec);
    margin-bottom: .35rem;
    font-weight: 500;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: .55rem .75rem;
    font-size: .9rem;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* ── Gumbi ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: .875rem;
    font-weight: 600;
    font-family: inherit;
    transition: background .15s, opacity .15s;
}
.btn-primary  { background: var(--primary); color: #fff; box-shadow: 0 3px 10px color-mix(in srgb, var(--primary) 45%, transparent); }
.btn-primary:hover { background: var(--primary-h); box-shadow: 0 4px 16px color-mix(in srgb, var(--primary) 60%, transparent); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-ghost    { background: transparent; color: var(--text-sec); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-sec); }
.btn-full     { width: 100%; justify-content: center; }
.btn-sm       { padding: .35rem .75rem; font-size: .8rem; }

/* ── Alert ── */
.alert {
    padding: .65rem .9rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: .875rem;
}
.alert-error   { background: #450a0a; border: 1px solid var(--danger); color: #fca5a5; }
.alert-success { background: #052e16; border: 1px solid var(--success); color: #86efac; }

/* ── Glavni layout (najemodajalec) ── */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
#app-header {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
    flex-shrink: 0;
    z-index: 10;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    box-shadow: var(--shadow-sm);
}
#app-header::-webkit-scrollbar { display: none; }
#app-header .logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    letter-spacing: -.5px;
    text-shadow: 0 0 16px color-mix(in srgb, var(--primary) 45%, transparent);
}
#app-header .user-info {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .75rem;
    color: var(--text-sec);
    font-size: .85rem;
}

/* Body: sidebar + main */
#app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
#sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform .3s ease;
    flex-shrink: 0;
    overflow: hidden;
}
#sidebar-header {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
#sidebar-header span {
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-sec);
    letter-spacing: .08em;
    text-transform: uppercase;
}
#sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: .5rem 0;
}

/* Objekt v sidebaru */
.sidebar-property {
    margin-bottom: .25rem;
}
.sidebar-property-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
    cursor: pointer;
    border-radius: 8px;
    margin: 0 .5rem;
    transition: background .12s;
    font-weight: 600;
    font-size: .875rem;
}
.sidebar-property-header:hover { background: var(--surface2); }
.sidebar-property-header.active { background: var(--primary); color: #fff; }
.sidebar-property-header .arrow {
    margin-left: auto;
    font-size: .75rem;
    transition: transform .2s;
}
.sidebar-property-header.open .arrow { transform: rotate(90deg); }

/* Gospodinjstvo */
.sidebar-household {
    margin: .15rem .5rem .15rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.sidebar-household-header {
    padding: .4rem .65rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-sec);
    background: var(--surface2);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .4rem;
    transition: background .12s;
}
.sidebar-household-header:hover { background: var(--border); }
.sidebar-household-header.active { color: var(--primary); }

/* Najemnik v sidebaru */
.sidebar-tenant {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem .65rem;
    font-size: .82rem;
    cursor: pointer;
    transition: background .12s;
    border-top: 1px solid var(--border);
}
.sidebar-tenant:hover { background: var(--surface2); }
.sidebar-tenant.active { background: var(--primary); color: #fff; }
.sidebar-tenant .avatar {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar-tenant.active .avatar { background: rgba(255,255,255,.3); }

/* Glavni panel */
#main-panel {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    padding-bottom: calc(1.5rem + var(--banner-h) + var(--copy-h));
    background: var(--bg);
}

/* Zavihki */
.tabs {
    display: flex;
    gap: .25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.tab-btn {
    padding: .55rem 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-sec);
    cursor: pointer;
    font-size: .875rem;
    font-weight: 500;
    font-family: inherit;
    transition: color .15s, border-color .15s;
    margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); text-shadow: 0 0 14px color-mix(in srgb, var(--primary) 50%, transparent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Kartice */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm), var(--shadow-inset);
    transition: box-shadow .2s, transform .2s;
}
.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow), 0 0 22px -4px color-mix(in srgb, var(--primary) 55%, transparent), var(--shadow-inset);
}
.card-title {
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-sec);
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}
.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: .75rem;
}
@media (max-width: 600px) {
    .field-row { grid-template-columns: 1fr; }
    .dropdown-menu {
        position: fixed;
        left: .75rem;
        right: .75rem;
        top: 4rem;
        min-width: auto;
        max-width: none;
        z-index: 300;
    }
}
.field-label {
    font-size: .78rem;
    color: var(--text-sec);
    margin-bottom: .2rem;
}
.field-value {
    font-size: .9rem;
    color: var(--text);
}

/* Badge */
.badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 99px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-green  { background: #052e16; color: #86efac; border: 1px solid var(--success); }
.badge-red    { background: #450a0a; color: #fca5a5; border: 1px solid var(--danger); }
.badge-yellow { background: #431407; color: #fde68a; border: 1px solid var(--warning); }

/* Tabela */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; padding: .6rem .75rem; color: var(--text-sec); font-size: .78rem; font-weight: 600; border-bottom: 1px solid var(--border); }
td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* Prazno stanje */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-sec);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: .75rem; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.75rem;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0,0,0,.4), var(--shadow-inset);
}
.modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
}
.modal-actions {
    display: flex;
    gap: .65rem;
    margin-top: 1.25rem;
    justify-content: flex-end;
}

/* Toast */
#toast {
    position: fixed;
    bottom: 1.5rem; left: 50%;
    transform: translateX(-50%);
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: .65rem 1.25rem;
    border-radius: 99px;
    font-size: .875rem;
    z-index: 200;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: var(--shadow);
}
#toast.show { opacity: 1; }

/* Tenant panel (mobilni) */
.tenant-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}
.tenant-tabs {
    display: flex;
    overflow-x: auto;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.tenant-tab {
    padding: .75rem 1.1rem;
    white-space: nowrap;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-sec);
    cursor: pointer;
    font-family: inherit;
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: -1px;
}
.tenant-tab.active { color: var(--primary); border-bottom-color: var(--primary); text-shadow: 0 0 14px color-mix(in srgb, var(--primary) 50%, transparent); }
.tenant-content { padding: 1rem; padding-bottom: calc(1rem + var(--banner-h) + var(--copy-h)); max-width: 640px; margin: 0 auto; }

/* ── Mobilni sidebar ── */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        top: var(--header-h);
        left: 0;
        bottom: 0;
        z-index: 50;
        box-shadow: 4px 0 20px rgba(0,0,0,.5);
    }
    #sidebar.sidebar-hidden {
        transform: translateX(calc(-1 * var(--sidebar-w) - 10px));
    }
    #sidebar-overlay {
        display: none;
        position: fixed;
        inset: var(--header-h) 0 0 0;
        background: rgba(0,0,0,.4);
        z-index: 49;
    }
    #sidebar-overlay.active { display: block; }
    #main-panel { width: 100%; }
    .logo { cursor: pointer; user-select: none; }
}
@media (min-width: 769px) {
    #sidebar-overlay { display: none !important; }
}

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + .4rem);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; min-width: 210px; z-index: 200;
    padding: .35rem 0; box-shadow: 0 8px 24px rgba(0,0,0,.45);
    display: none;
}
.dropdown-menu.open { display: block; }
.dropdown-item {
    display: block; width: 100%; padding: .55rem 1rem;
    background: none; border: none; text-align: left;
    color: var(--text); font-size: .875rem; font-family: inherit;
    cursor: pointer; transition: background .12s;
}
.dropdown-item:hover { background: var(--surface2); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Promo banner ── */
#promo-banner {
    position: fixed; bottom: calc(var(--copy-h) + 4px); left: 0; right: 0; z-index: 99;
    height: var(--banner-h);
    background: var(--surface2); border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
}
#promo-link {
    font-size: .72rem; font-weight: 600; color: var(--text-sec);
    text-decoration: none; display: flex; align-items: center; gap: .35rem;
    padding: 0 1rem; width: 100%; justify-content: center;
    transition: opacity .5s, color .15s;
}
#promo-link:active { opacity: .7; }
#promo-link:hover  { color: var(--text); }

/* ── SMS podzavihki ── */
.sms-subtabs {
    display: flex; gap: .35rem; margin-bottom: 1rem;
    border-bottom: 1px solid var(--border); padding-bottom: .5rem;
}
.sms-subtab {
    background: none; border: none; cursor: pointer;
    color: var(--text-sec); font-size: .875rem; font-family: inherit;
    padding: .35rem .75rem; border-radius: 6px; transition: background .15s, color .15s;
}
.sms-subtab:hover { background: var(--surface2); color: var(--text); }
.sms-subtab.active {
    background: var(--surface2); color: var(--primary); font-weight: 600;
}

/* ── Incident prikaz ── */
.inc-mobile { display: none; }
.inc-card {
    border-bottom: 1px solid var(--border);
    padding: .75rem 1rem;
}
.inc-card:last-child { border-bottom: none; }
.inc-card-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: .35rem;
}
.inc-card-datum {
    font-size: .8rem; font-weight: 600; color: var(--primary);
}
.inc-card-opis {
    font-size: .875rem; line-height: 1.45; margin-bottom: .3rem;
}
.inc-card-ukrep {
    font-size: .8rem; color: var(--text-sec);
}
.inc-card-label {
    font-weight: 600;
}
@media (max-width: 600px) {
    .inc-desktop { display: none; }
    .inc-mobile  { display: block; }
}

/* ── Copyright footer ── */
#copyright-footer {
    position: fixed; bottom: 4px; left: 0; right: 0; z-index: 99;
    height: var(--copy-h);
    background: var(--surface2); border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center; gap: .5rem;
    font-size: .63rem; color: var(--text-sec); opacity: .7;
    user-select: none; pointer-events: none;
}
