:root {
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    color: #111827;
    background: #f3f4f6;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 0;
    background: #f3f4f6;
}

body {
    margin: 0;
    min-width: 0;
    background: #f3f4f6;
    color: #111827;
}

body.menu-open {
    overflow: hidden;
}

a {
    color: #1d4ed8;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

/* --------------------------------------------------------------------------
   Glavni layout
   -------------------------------------------------------------------------- */

.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
    min-height: 100vh;
    padding: 24px 18px;

    display: flex;
    flex-direction: column;

    background: #111827;
    color: #fff;
}

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

.brand {
    margin-bottom: 28px;

    font-size: 20px;
    font-weight: 800;
    line-height: 1.2;
}

.sidebar-close {
    display: none;
}

.sidebar-nav {
    min-width: 0;
}

.sidebar a {
    display: block;
    margin: 3px 0;
    padding: 10px 12px;

    color: #d1d5db;
    border-radius: 8px;

    line-height: 1.35;
}

.sidebar a:hover {
    background: #1f2937;
    color: #fff;
    text-decoration: none;
}

.sidebar .section {
    margin: 22px 12px 6px;

    color: #9ca3af;

    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 18px;
}

.sidebar-footer form {
    margin: 0;
}

.sidebar-logout {
    width: 100%;
}

.main {
    min-width: 0;
}

.sidebar-backdrop {
    display: none;
}

/* --------------------------------------------------------------------------
   Gornja traka
   -------------------------------------------------------------------------- */

.topbar {
    min-height: 66px;
    padding: 12px 28px;

    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;

    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}

.mobile-menu-toggle {
    display: none;
}

.topbar-main {
    min-width: 0;

    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.topbar-company {
    min-width: 0;
    overflow-wrap: anywhere;
}

.topbar-license {
    color: #6b7280;
    font-size: 13px;
}

.topbar-license::before {
    content: "·";
    margin-right: 8px;
}

.topbar-user {
    min-width: 0;

    display: flex;
    flex-direction: column;
    align-items: flex-end;

    line-height: 1.25;
    text-align: right;
}

.topbar-user-name {
    color: #111827;
    font-weight: 650;
}

.topbar-user-email {
    max-width: 310px;
    margin-top: 2px;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    color: #6b7280;
    font-size: 13px;
}

/* --------------------------------------------------------------------------
   Sadržaj
   -------------------------------------------------------------------------- */

.content {
    width: 100%;
    max-width: 1200px;
    padding: 28px;
}

.card {
    margin-bottom: 20px;
    padding: 22px;

    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;

    box-shadow: 0 1px 2px rgba(0, 0, 0, .03);
}

/* --------------------------------------------------------------------------
   Login / autentikacija
   -------------------------------------------------------------------------- */

.auth-wrap {
    min-height: 100vh;
    padding: 24px;

    display: grid;
    place-items: center;
}

.auth-card {
    width: min(460px, 100%);
    padding: 30px;

    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
}

/* --------------------------------------------------------------------------
   Obrasci i kontrole
   -------------------------------------------------------------------------- */

label {
    display: block;
    margin: 14px 0 6px;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    padding: 11px 12px;

    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
}

button,
.button {
    display: inline-block;
    padding: 10px 14px;

    background: #111827;
    color: #fff;
    border: 0;
    border-radius: 8px;

    cursor: pointer;
}

.button:hover {
    opacity: .92;
    text-decoration: none;
}

.button.secondary,
button.secondary {
    background: #e5e7eb;
    color: #111827;
}

.button.danger,
button.danger {
    background: #991b1b;
}

.button.success,
button.success {
    background: #166534;
}

.row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.actions form {
    margin: 0;
}

/* --------------------------------------------------------------------------
   Poruke
   -------------------------------------------------------------------------- */

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 8px;
}

.alert.success {
    background: #dcfce7;
    color: #14532d;
}

.alert.error {
    background: #fee2e2;
    color: #7f1d1d;
}

.muted {
    color: #6b7280;
}

/* --------------------------------------------------------------------------
   Tablice
   -------------------------------------------------------------------------- */

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 10px;

    vertical-align: top;
    text-align: left;

    border-bottom: 1px solid #e5e7eb;
}

th {
    color: #4b5563;
    font-size: 13px;
}

/* --------------------------------------------------------------------------
   Statusi
   -------------------------------------------------------------------------- */

.badge {
    display: inline-block;
    padding: 4px 8px;

    background: #e5e7eb;
    border-radius: 999px;

    font-size: 12px;
}

.badge.active {
    background: #dcfce7;
    color: #166534;
}

.badge.blocked {
    background: #fee2e2;
    color: #991b1b;
}

.badge.pending {
    background: #fef3c7;
    color: #92400e;
}

/* --------------------------------------------------------------------------
   Dashboard
   -------------------------------------------------------------------------- */

h1 {
    margin-top: 0;
}

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

.stat {
    font-size: 26px;
    font-weight: 800;
}

/* --------------------------------------------------------------------------
   Tablet
   -------------------------------------------------------------------------- */

@media (max-width: 1000px) and (min-width: 801px) {
    .shell {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .sidebar {
        padding-left: 14px;
        padding-right: 14px;
    }

    .content {
        padding: 22px;
    }

    .topbar {
        padding-left: 22px;
        padding-right: 22px;
    }
}

/* --------------------------------------------------------------------------
   Mobitel
   -------------------------------------------------------------------------- */

@media (max-width: 800px) {

    .shell {
        display: block;
        min-height: 100vh;
    }

    .sidebar {
        position: fixed;
        z-index: 1001;

        top: 0;
        left: 0;
        bottom: 0;

        width: min(320px, 86vw);
        min-height: 100dvh;
        padding:
            calc(18px + env(safe-area-inset-top))
            16px
            calc(18px + env(safe-area-inset-bottom));

        overflow-y: auto;

        transform: translateX(-105%);
        transition: transform .22s ease;

        box-shadow: 20px 0 45px rgba(0, 0, 0, .24);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-head {
        margin-bottom: 16px;
    }

    .brand {
        margin: 0;
        font-size: 20px;
    }

    .sidebar-close {
        width: 42px;
        height: 42px;
        padding: 0;

        display: grid;
        place-items: center;
        flex: 0 0 42px;

        background: #1f2937;
        color: #fff;
        border-radius: 10px;

        font-size: 29px;
        line-height: 1;
    }

    .sidebar .section {
        margin-top: 19px;
    }

    .sidebar a {
        padding: 12px 12px;
        font-size: 15px;
    }

    .sidebar-backdrop {
        position: fixed;
        z-index: 1000;

        inset: 0;

        display: block;

        background: rgba(15, 23, 42, .52);

        opacity: 0;
        visibility: hidden;

        transition:
            opacity .22s ease,
            visibility .22s ease;
    }

    .sidebar-backdrop.open {
        opacity: 1;
        visibility: visible;
    }

    .main {
        width: 100%;
        min-width: 0;
    }

    .topbar {
        position: sticky;
        z-index: 900;
        top: 0;

        min-height: 64px;
        padding:
            calc(9px + env(safe-area-inset-top))
            14px
            9px;

        grid-template-columns: 44px minmax(0, 1fr) auto;
        gap: 10px;

        box-shadow: 0 1px 0 rgba(17, 24, 39, .04);
    }

    .mobile-menu-toggle {
        width: 42px;
        height: 42px;
        padding: 10px;

        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: center;
        gap: 4px;

        background: #111827;
        border-radius: 10px;
    }

    .mobile-menu-toggle span {
        display: block;
        width: 100%;
        height: 2px;

        background: #fff;
        border-radius: 999px;
    }

    .topbar-main {
        gap: 0;
        display: block;
    }

    .topbar-company {
        display: block;

        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;

        font-size: 14px;
    }

    .topbar-license {
        display: block;
        margin-top: 2px;

        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;

        font-size: 11px;
    }

    .topbar-license::before {
        display: none;
    }

    .topbar-user {
        max-width: 40vw;
        align-items: flex-end;
    }

    .topbar-user-name {
        max-width: 100%;

        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;

        font-size: 13px;
    }

    .topbar-user-email {
        max-width: 100%;
        font-size: 10px;
    }

    .content {
        max-width: none;
        padding: 18px 14px 28px;
    }

    .grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .card {
        padding: 18px;
        border-radius: 12px;
    }

    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .actions {
        gap: 6px;
    }
}

/* --------------------------------------------------------------------------
   Mali mobiteli
   -------------------------------------------------------------------------- */

@media (max-width: 480px) {

    .topbar {
        grid-template-columns: 42px minmax(0, 1fr);
    }

    .topbar-user {
        grid-column: 2;
        max-width: 100%;

        margin-top: -4px;

        align-items: flex-start;
        text-align: left;
    }

    .topbar-main {
        grid-column: 2;
    }

    .topbar-user-email {
        display: none;
    }

    .content {
        padding-left: 12px;
        padding-right: 12px;
    }

    .auth-wrap {
        padding: 14px;
    }

    .auth-card {
        padding: 22px 18px;
    }

    .row {
        align-items: stretch;
    }

    .row > .button,
    .row > button {
        text-align: center;
    }
}
