:root {
    color-scheme: light;
    --bg: #f6f8fc;
    --panel: #ffffff;
    --text: #171b35;
    --muted: #65718a;
    --line: #dfe6f3;
    --brand: #0d8fd3;
    --brand-dark: #1d357e;
    --brand-purple: #8a3ffc;
    --cyan: #19d8e8;
    --blue: #2362b8;
    --red: #b42318;
    --amber: #9a5b00;
    --green: #1f7a3f;
    --shadow: 0 16px 42px rgba(23, 27, 53, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 8% 0%, rgba(25, 216, 232, .14), transparent 34%),
        linear-gradient(180deg, #fbfdff 0%, var(--bg) 38%, #eef3fb 100%);
    color: var(--text);
    font-family: Aptos, "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    background: #fff;
    color: var(--text);
    font-weight: 400;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(13, 143, 211, .7);
    box-shadow: 0 0 0 4px rgba(13, 143, 211, .12);
    outline: 0;
}

textarea {
    resize: vertical;
}

label {
    display: grid;
    gap: 7px;
    color: #334155;
    font-weight: 500;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 20px;
    padding: 14px 28px;
    border-bottom: 1px solid rgba(223, 230, 243, .84);
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    letter-spacing: 0;
}

.brand img {
    width: 40px;
    height: auto;
}

.brand span {
    display: grid;
    line-height: 1.05;
}

.brand small {
    color: var(--muted);
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
}

.nav,
.logout,
.filters,
.meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav a,
.logout button,
.filters a,
.button {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 13px;
    background: #fff;
    color: #1f2937;
    cursor: pointer;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    transition: border-color .16s ease, box-shadow .16s ease, color .16s ease, background .16s ease, transform .16s ease;
}

.nav a:hover,
.logout button:hover,
.filters a:hover,
.button:hover {
    border-color: rgba(13, 143, 211, .38);
    color: var(--brand-dark);
    box-shadow: 0 8px 18px rgba(23, 27, 53, .07);
    transform: translateY(-1px);
}

.nav a:focus-visible,
.logout button:focus-visible,
.filters a:focus-visible,
.button:focus-visible,
.profile-link:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 4px rgba(13, 143, 211, .14);
}

.button-primary,
.nav .button-primary {
    border-color: transparent;
    background: linear-gradient(135deg, var(--brand), var(--brand-purple));
    color: #fff;
    box-shadow: 0 10px 20px rgba(13, 143, 211, .2);
}

.button-primary:hover {
    color: #fff;
    background: linear-gradient(135deg, var(--brand-dark), var(--brand-purple));
}

.button-soft {
    border-color: rgba(13, 143, 211, .18);
    background: rgba(231, 248, 255, .78);
    color: var(--brand-dark);
}

.logout button {
    background: transparent;
}

.profile-link {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--brand-dark);
    font-weight: 600;
    line-height: 1;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 48px;
}

.hero,
.page-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.hero {
    position: relative;
    overflow: hidden;
    min-height: 170px;
    padding: 28px;
    border: 1px solid rgba(223, 230, 243, .9);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(25, 216, 232, .18), rgba(138, 63, 252, .12)),
        #fff;
}

.hero::after {
    content: "";
    position: absolute;
    right: -90px;
    bottom: -180px;
    width: 430px;
    height: 460px;
    background: url("dekoracija.png") center / contain no-repeat;
    opacity: .5;
    pointer-events: none;
}

.hero > * {
    position: relative;
    z-index: 1;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    max-width: 760px;
    margin-bottom: 0;
    font-size: clamp(2rem, 5vw, 3.8rem);
    font-weight: 650;
    line-height: 1.05;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 16px;
    font-size: 1.1rem;
    font-weight: 650;
}

.eyebrow {
    margin-bottom: 8px;
    color: var(--brand-dark);
    font-size: .78rem;
    font-weight: 650;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.muted,
.empty,
.hint {
    color: var(--muted);
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stats article,
.panel,
.login-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.stats article {
    position: relative;
    padding: 18px;
}

.stats article > .icon {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 22px;
    height: 22px;
    color: var(--brand);
    opacity: .82;
}

.stats strong {
    display: block;
    padding-right: 28px;
    font-size: clamp(1.55rem, 3vw, 2rem);
    font-weight: 650;
    line-height: 1.12;
    overflow-wrap: anywhere;
}

.stats span {
    color: var(--muted);
}

.grid {
    display: grid;
    gap: 18px;
}

.grid.two {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
}

.grid.detail {
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: start;
    margin-bottom: 18px;
}

.grid.catalog-grid {
    grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
    align-items: start;
    margin-bottom: 18px;
}

.panel {
    padding: 20px;
}

.panel.narrow {
    max-width: 820px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.compose,
.stack {
    display: grid;
    gap: 14px;
}

.compose {
    margin-bottom: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.check-row {
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    gap: 10px;
    width: fit-content;
}

.check-row input {
    width: auto;
}

.feed,
.task-list,
.data-list {
    display: grid;
    gap: 10px;
}

.data-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.data-row-link {
    grid-template-columns: auto minmax(0, 1fr) auto;
}

.data-row:hover,
.data-row-link:hover {
    border-color: rgba(13, 143, 211, .38);
    box-shadow: 0 8px 18px rgba(23, 27, 53, .07);
}

.data-row strong,
.data-row small {
    display: block;
    overflow-wrap: break-word;
}

.data-row small {
    color: var(--muted);
}

.amount {
    color: var(--brand-dark);
    white-space: nowrap;
}

.feed-item {
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.feed-item div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: .9rem;
}

.feed-item p {
    margin-bottom: 0;
}

.task-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.task-row:hover {
    border-color: #9fb0c3;
}

.task-main {
    min-width: 0;
}

.task-main strong,
.task-main small {
    display: block;
    overflow-wrap: anywhere;
}

.task-main small {
    color: var(--muted);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 28px;
    border-radius: 999px;
    padding: 4px 9px;
    background: #eef2f7;
    color: #334155;
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge .icon {
    width: 14px;
    height: 14px;
    flex-basis: 14px;
    stroke-width: 2.2;
}

.status-open {
    background: #e8eef9;
    color: var(--blue);
}

.status-in_progress {
    background: #e7f8ff;
    color: var(--brand-dark);
}

.status-waiting {
    background: #fff3d6;
    color: var(--amber);
}

.status-done {
    background: #e8f6ed;
    color: var(--green);
}

.priority-urgent {
    background: #fee4e2;
    color: var(--red);
}

.priority-high {
    background: #fff3d6;
    color: var(--amber);
}

.filters {
    margin-bottom: 16px;
}

.filters a.active {
    border-color: var(--brand);
    background: #e7f8ff;
    color: var(--brand-dark);
    box-shadow: inset 0 0 0 1px rgba(13, 143, 211, .08);
}

.description {
    margin: 22px 0 0;
    color: #334155;
    white-space: normal;
}

.items-editor {
    display: grid;
    gap: 10px;
}

.items-head,
.item-row {
    display: grid;
    grid-template-columns: minmax(150px, .9fr) minmax(220px, 1.5fr) 90px 90px 120px;
    gap: 10px;
    align-items: center;
}

.items-head {
    color: var(--muted);
    font-size: .82rem;
    font-weight: 600;
    text-transform: uppercase;
}

.table-wrap {
    overflow-x: auto;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: #f3f4f6;
}

.items-table th,
.items-table td {
    border-bottom: 1px solid #e5e7eb;
    padding: 11px 10px;
    text-align: left;
    vertical-align: top;
}

.items-table th {
    background:
        linear-gradient(90deg, rgba(24, 182, 178, .92), rgba(31, 123, 214, .92) 55%, rgba(59, 63, 140, .92)),
        url("invoice-header-gradient.png") center / 100% 100% no-repeat;
    color: #fff;
    font-size: .78rem;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.items-table th:first-child,
.items-table td:first-child {
    width: 48px;
    text-align: center;
    white-space: nowrap;
}

.items-table th:nth-child(2),
.items-table td:nth-child(2) {
    width: auto;
}

.items-table th:nth-child(3),
.items-table td:nth-child(3) {
    width: 78px;
}

.items-table th:nth-child(4),
.items-table td:nth-child(4) {
    width: 96px;
}

.items-table th:nth-child(5),
.items-table td:nth-child(5),
.items-table th:nth-child(6),
.items-table td:nth-child(6) {
    width: 112px;
}

.items-table th:nth-child(n+4),
.items-table td:nth-child(n+4) {
    text-align: right;
    white-space: nowrap;
}

.items-table tbody tr:nth-child(odd) td:nth-child(odd),
.items-table tbody tr:nth-child(even) td:nth-child(even) {
    background: rgba(243, 244, 246, .65);
}

.items-table tbody tr:nth-child(odd) td:nth-child(even),
.items-table tbody tr:nth-child(even) td:nth-child(odd) {
    background: rgba(221, 220, 225, .35);
}

.document-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, .55fr);
    gap: 18px;
    margin-bottom: 22px;
}

.document-summary strong {
    display: block;
    margin: 3px 0 6px;
    font-size: 1.1rem;
}

.total-amount {
    color: var(--brand-dark);
    font-size: 1.7rem !important;
}

.side-facts {
    margin-top: 18px;
    color: #334155;
}

.side-facts p {
    margin-bottom: 8px;
}

.profile-panel {
    overflow: hidden;
}

.profile-security {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: -4px 0 18px;
    padding: 16px;
    border: 1px solid rgba(13, 143, 211, .16);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(25, 216, 232, .12), rgba(138, 63, 252, .1));
}

.profile-security h2 {
    margin-bottom: 3px;
}

.profile-security p {
    margin-bottom: 0;
}

.security-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 8px;
    background: #fff;
    color: var(--brand-dark);
    box-shadow: 0 10px 24px rgba(23, 27, 53, .08);
}

.security-icon .icon {
    width: 25px;
    height: 25px;
}

.print-page {
    background: #eef3fb;
    color: #172033;
}

.print-sheet {
    position: relative;
    width: min(794px, calc(100% - 32px));
    min-height: 1123px;
    margin: 28px auto;
    padding: 68px 68px 118px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(45deg, rgba(229, 231, 235, .34) 25%, transparent 25%) 0 0 / 70px 70px,
        linear-gradient(135deg, rgba(229, 231, 235, .34) 25%, transparent 25%) 0 0 / 70px 70px,
        #f3f4f6;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.print-decor {
    position: absolute;
    right: -22px;
    bottom: -14px;
    width: 260px;
    height: auto;
    opacity: .95;
    pointer-events: none;
}

.print-header {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 44px;
}

.print-brand {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.print-brand img {
    width: 82px;
    height: auto;
}

.print-brand strong,
.print-brand span,
.print-document-title span,
.print-document-title p {
    display: block;
}

.print-brand strong {
    margin-top: 28px;
    color: #111827;
    font-size: 1.25rem;
    font-weight: 900;
    letter-spacing: .03em;
    line-height: 1;
}

.print-brand span,
.print-document-title p {
    color: var(--muted);
    font-size: .75rem;
}

.print-document-title {
    margin-left: auto;
    text-align: right;
}

.print-document-title h1 {
    margin: 0 0 7px;
    color: #111827;
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: .04em;
    line-height: 1;
}

.print-document-meta {
    margin-left: auto;
    border-collapse: collapse;
    color: #111827;
    font-size: .76rem;
    line-height: 1.2;
}

.print-document-meta td {
    padding: 2px 0 2px 12px;
    text-align: right;
}

.print-document-meta td:first-child {
    font-weight: 650;
}

.print-parties {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin: 0 0 34px;
}

.print-party-card {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.print-parties h2,
.print-signature span {
    margin-bottom: 10px;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.print-parties p {
    margin-bottom: 2px;
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.25;
}

.print-parties p strong {
    color: #111827;
    font-size: 1rem;
}

.print-summary {
    position: relative;
    z-index: 1;
    width: 38%;
    margin: 14px 0 0 auto;
}

.print-payment {
    padding: 26px 0 0 32px;
    color: #111827;
}

.print-payment p {
    color: #111827;
}

.print-total {
    border: 0;
    border-radius: 0;
    overflow: visible;
    font-size: .78rem;
}

.print-total div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 3px 5px 3px 0;
    border-bottom: 0;
}

.print-total span {
    color: #111827;
    font-size: .78rem;
    font-weight: 500;
}

.print-total strong {
    color: #111827;
    font-size: .78rem;
    font-weight: 500;
    white-space: nowrap;
}

.print-total-due {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    padding: 9px 10px 10px 14px;
    color: #fff;
    background:
        linear-gradient(90deg, rgba(24, 182, 178, .92), rgba(31, 123, 214, .92) 55%, rgba(59, 63, 140, .92)),
        url("invoice-header-gradient.png") center / 100% 100% no-repeat;
}

.print-total-due strong {
    color: #fff;
    font-size: .95rem;
    white-space: nowrap;
}

.print-total-due span {
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
}

.print-note {
    position: relative;
    z-index: 1;
    width: 55%;
    margin-top: 16px;
    padding: 0;
    border: 0;
    border-radius: 0;
    color: var(--muted);
    background: transparent;
    font-size: .78rem;
    line-height: 1.25;
}

.print-note h2 {
    display: inline;
    margin: 0;
    color: #111827;
    font-size: .78rem;
    letter-spacing: 0;
    text-transform: none;
}

.print-note p {
    display: inline;
    margin-bottom: 0;
}

.print-signature {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 32px;
    margin-top: 46px;
}

.print-signature div:last-child {
    min-height: 58px;
    border-bottom: 1px solid #96a3b8;
}

.print-signature strong {
    display: block;
    margin-top: 6px;
}

.print-footer {
    position: absolute;
    left: 68px;
    right: 300px;
    bottom: 38px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
    color: var(--muted);
    font-size: .78rem;
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #334155;
}

.meta-item .icon {
    width: 16px;
    height: 16px;
    color: var(--brand-dark);
}

.flash {
    margin-bottom: 16px;
    border: 1px solid #b7e4c7;
    border-radius: 8px;
    padding: 12px 14px;
    background: #edfdf3;
    color: #14532d;
}

.flash.error {
    border-color: #fecaca;
    background: #fff1f2;
    color: #9f1239;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        url("dekoracija.png") right -210px bottom -250px / min(620px, 82vw) auto no-repeat,
        radial-gradient(circle at 18% 12%, rgba(25, 216, 232, .2), transparent 32%),
        linear-gradient(135deg, #ffffff 0%, #f5f8ff 44%, #eef3fb 100%);
}

.login-card {
    width: min(460px, 100%);
    padding: 28px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(14px);
}

.login-logo {
    display: block;
    width: 88px;
    height: auto;
    margin-bottom: 12px;
}

.login-card h1 {
    font-size: 2.35rem;
}

.hint {
    margin: 16px 0 0;
    font-size: .9rem;
}

@media (max-width: 860px) {
    .topbar,
    .hero,
    .page-title {
        align-items: stretch;
    }

    .topbar {
        grid-template-columns: 1fr;
    }

    .grid.two,
    .grid.detail,
    .grid.catalog-grid,
    .stats,
    .document-summary,
    .print-parties,
    .print-summary,
    .print-signature,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .hero,
    .page-title {
        flex-direction: column;
    }

    .task-row {
        grid-template-columns: 1fr;
    }

    .data-row,
    .data-row-link,
    .items-head,
    .item-row {
        grid-template-columns: 1fr;
    }

    .items-head {
        display: none;
    }

    .print-sheet {
        padding: 34px 24px 110px;
    }

    .print-header {
        flex-direction: column;
    }

    .print-document-title {
        margin-left: 0;
        text-align: left;
    }

    .print-document-meta {
        margin-left: 0;
    }

    .print-document-meta td {
        text-align: left;
    }

    .print-payment {
        padding: 0;
    }

    .print-summary,
    .print-note {
        width: 100%;
    }

    .print-footer {
        right: 24px;
        left: 24px;
    }
}

@page {
    size: A4;
    margin: 0;
}

@media print {
    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body,
    .print-page {
        background: #fff;
    }

    .print-sheet {
        width: 210mm;
        min-height: 297mm;
        margin: 0;
        padding: 18mm 18mm 32mm;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        overflow: visible;
    }

    .print-decor {
        right: -8mm;
        bottom: 0;
        width: 74mm;
    }

    .print-footer {
        left: 18mm;
        right: 95mm;
        bottom: 10mm;
    }

    .no-print {
        display: none !important;
    }

    .print-header,
    .print-parties,
    .print-summary,
    .print-note,
    .print-signature,
    .print-footer {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .table-wrap {
        overflow: visible;
    }

    .items-table {
        page-break-inside: auto;
    }

    .items-table tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .items-table th,
    .items-table td {
        border-color: #d8dee8;
    }
}
