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

:root {
    --paper: #f6f0e3;
    --paper-2: #efe7d7;
    --card: #fffefb;
    --ink: #1f1c18;
    --ink-2: #5a5348;
    --ink-3: #6e675b;
    --bronze: #8a6630;
    --butter: #f3cf6e;
    --line: #e8e0d0;
    --line-2: #dcd2bf;
    --green: #2e6b45;
    --red: #a3392b;
    --serif: 'EB Garamond', Georgia, serif;
    --sans: 'Jost', -apple-system, 'Segoe UI', sans-serif;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(60, 46, 20, 0.06), 0 8px 24px -16px rgba(60, 46, 20, 0.25);
}

html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--sans); color: var(--ink); background: var(--paper); line-height: 1.5; font-size: 15px; }
a { color: inherit; }
button, select, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--bronze); outline-offset: 2px; }

/* ===== gornja traka ===== */
.top {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
    padding: 12px 24px;
    background: rgba(255, 254, 251, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--serif); font-size: 1.45rem; font-weight: 500; white-space: nowrap; }
.brand svg { width: 28px; height: 28px; }
.brand em { color: var(--bronze); }
.tabs { display: flex; gap: 4px; background: var(--paper-2); border-radius: 999px; padding: 4px; }
.tabs button {
    border: 0; background: transparent; cursor: pointer;
    padding: 8px 16px; border-radius: 999px;
    font-size: 0.86rem; font-weight: 500;
}
.tabs button.active { background: var(--ink); color: var(--card); }
.top-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }
.top-actions form { display: contents; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: 40px; padding: 0 16px;
    border-radius: 6px; border: 1px solid var(--ink);
    background: var(--ink); color: var(--card);
    font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
    text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #3b362e; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--ink); background: var(--card); }
.btn.soft { background: #efe8db; color: var(--ink); border-color: #efe8db; }
.btn.soft:hover { background: var(--ink); color: var(--card); }
.btn.danger { background: transparent; color: var(--red); border-color: rgba(163, 57, 43, 0.4); }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn svg { width: 16px; height: 16px; }

main { max-width: 1320px; margin: 0 auto; padding: 24px 24px 80px; }
h2 { font-family: var(--serif); font-weight: 500; font-size: 1.8rem; line-height: 1.15; }
h3 { font-family: var(--serif); font-weight: 500; font-size: 1.35rem; margin-bottom: 12px; }
.muted { color: var(--ink-3); }

/* ===== nadolazeće dostave ===== */
.upcoming { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 22px; }
.day-card {
    text-align: left; cursor: pointer;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 14px 16px; box-shadow: var(--shadow);
}
.day-card:hover { border-color: var(--ink-3); }
.day-card .d { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--bronze); }
.day-card .z { font-family: var(--serif); font-size: 1.25rem; line-height: 1.2; margin: 2px 0 8px; }
.day-card .n { font-size: 0.85rem; color: var(--ink-2); }
.day-card .n b { color: var(--ink); font-size: 1.05rem; }

/* ===== filteri ===== */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    border: 1px solid var(--line-2); background: var(--card); cursor: pointer;
    border-radius: 999px; padding: 6px 13px; font-size: 0.84rem; font-weight: 500;
}
.chip b { font-weight: 600; margin-left: 4px; color: var(--ink-3); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--card); }
.chip.active b { color: var(--butter); }
.filters select, .filters input, .field input, .field textarea, .field select {
    min-height: 40px; padding: 8px 12px;
    border: 1px solid var(--line-2); border-radius: 6px; background: var(--card);
}
.filters input[type="search"] { flex: 1; min-width: 200px; }

/* ===== narudžbe ===== */
.orders { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.order {
    background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--line-2);
    border-radius: var(--radius); box-shadow: var(--shadow);
    display: flex; flex-direction: column;
}
.order.st-nova { border-left-color: #e0b53e; }
.order.st-potvrdena { border-left-color: #4f7fae; }
.order.st-priprema { border-left-color: #c9822f; }
.order.st-dostavljena { border-left-color: var(--green); }
.order.st-otkazana { border-left-color: #b9b2a6; opacity: 0.7; }
.order.is-new { box-shadow: 0 0 0 2px var(--butter), var(--shadow); }
.o-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px dashed var(--line); }
.o-num { font-weight: 600; font-size: 1rem; }
.o-when { font-size: 0.84rem; color: var(--ink-2); margin-top: 2px; }
.o-when b { color: var(--ink); font-weight: 600; }
.o-body { padding: 12px 16px; display: grid; gap: 10px; flex: 1; }
.o-cust { display: grid; gap: 2px; font-size: 0.9rem; }
.o-cust .nm { font-weight: 600; font-size: 0.98rem; }
.o-cust a { text-decoration: none; color: var(--ink-2); }
.o-cust a:hover { color: var(--bronze); text-decoration: underline; }
.o-items { list-style: none; display: grid; gap: 4px; font-size: 0.88rem; }
.o-items li { display: flex; justify-content: space-between; gap: 10px; }
.o-items li small { display: block; color: var(--ink-3); font-size: 0.78rem; }
.o-items li span:last-child { white-space: nowrap; color: var(--ink-2); }
.o-total { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 0.9rem; padding-top: 8px; border-top: 1px solid var(--line); }
.o-total b { font-weight: 600; }
.o-total .final { color: var(--green); font-weight: 600; }
.o-note { font-size: 0.85rem; background: var(--paper); border-radius: 6px; padding: 7px 10px; color: var(--ink-2); }
.o-note.admin { background: #fbf3d7; }
.o-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px 12px; font-size: 0.8rem; color: var(--ink-3); }
.linkbtn { border: 0; background: none; cursor: pointer; font-weight: 600; font-size: 0.82rem; color: var(--bronze); text-decoration: underline; text-underline-offset: 3px; }

.status {
    border-radius: 999px; border: 1px solid transparent; padding: 5px 28px 5px 12px; cursor: pointer;
    font-size: 0.8rem; font-weight: 600; appearance: none;
    background: var(--paper-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%231f1c18' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center;
}
.status.st-nova { background-color: #fbecc0; }
.status.st-potvrdena { background-color: #dde8f3; }
.status.st-priprema { background-color: #f6e0c6; }
.status.st-dostavljena { background-color: #d9ebde; }
.status.st-otkazana { background-color: #ebe7e0; color: var(--ink-3); }

.empty { text-align: center; padding: 60px 20px; color: var(--ink-3); background: var(--card); border: 1px dashed var(--line-2); border-radius: var(--radius); }

/* ===== dostava i priprema ===== */
.prep-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.slot-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 6px 0 26px; }
.slot-cell { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.slot-cell .l { font-size: 0.82rem; font-weight: 600; }
.slot-cell .bar { height: 6px; border-radius: 99px; background: var(--paper-2); margin: 8px 0 4px; overflow: hidden; }
.slot-cell .bar i { display: block; height: 100%; background: var(--bronze); border-radius: 99px; }
.slot-cell.full .bar i { background: var(--red); }
.slot-cell .c { font-size: 0.78rem; color: var(--ink-3); }
.shift-label { grid-column: 1 / -1; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); margin-top: 4px; }
.two-col { display: grid; grid-template-columns: minmax(280px, 0.8fr) 1.2fr; gap: 26px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
table.prep { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.prep th { text-align: left; font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; padding: 6px 6px; border-bottom: 1px solid var(--line-2); }
table.prep td { padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.prep td.num, table.prep th.num { text-align: right; white-space: nowrap; }
table.prep tfoot td { font-weight: 600; border-bottom: 0; }
.route-slot { margin-bottom: 16px; }
.route-slot h4 { font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--bronze); margin-bottom: 6px; }
.stop { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 0.9rem; }
.stop .who { font-weight: 600; }
.stop .addr, .stop .items { color: var(--ink-2); font-size: 0.85rem; }
.stop .side { text-align: right; display: grid; gap: 6px; justify-items: end; }
.stop.done .who { text-decoration: line-through; color: var(--ink-3); }

/* ===== uređivanje (ladica) ===== */
.drawer-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(31, 28, 24, 0.45); display: flex; justify-content: flex-end; }
.drawer { width: min(520px, 100%); height: 100%; overflow-y: auto; background: var(--paper); padding: 22px 24px 40px; box-shadow: -20px 0 50px rgba(0, 0, 0, 0.2); }
.drawer-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.x { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--card); cursor: pointer; font-size: 1.2rem; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 0.9rem; margin: 10px 0 18px; }
.kv dt { color: var(--ink-3); }
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 0.8rem; font-weight: 600; color: var(--ink-2); }
.field textarea { min-height: 80px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

dialog { border: 0; border-radius: 12px; padding: 22px 24px; width: min(420px, 92vw); background: var(--paper); color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3); }
dialog::backdrop { background: rgba(31, 28, 24, 0.45); }
.err { color: var(--red); font-size: 0.85rem; min-height: 1.2em; }

.toast {
    position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(120px);
    background: var(--ink); color: var(--card); padding: 12px 22px; border-radius: 999px;
    font-size: 0.88rem; font-weight: 500; transition: transform 0.3s ease; z-index: 60; max-width: calc(100vw - 32px);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ===== prijava ===== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(380px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px; box-shadow: var(--shadow); text-align: center; }
.login .brand { justify-content: center; font-size: 1.7rem; margin-bottom: 4px; }
.login p { color: var(--ink-3); font-size: 0.9rem; margin-bottom: 20px; }
.login input { width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--paper); margin-bottom: 12px; font-size: 1rem; }
.login .btn { width: 100%; min-height: 46px; }

/* ===== mobitel ===== */
@media (max-width: 760px) {
    body { font-size: 14.5px; }
    .top { padding: 10px 14px; gap: 10px; }
    .tabs { order: 3; width: 100%; }
    .tabs button { flex: 1; }
    .top-actions .btn { padding: 0 11px; min-height: 36px; font-size: 0.72rem; }
    main { padding: 16px 14px 70px; }
    .orders { grid-template-columns: 1fr; }
    .upcoming { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -14px 18px; padding: 2px 14px 6px; }
    .day-card { flex: 0 0 72%; scroll-snap-align: start; }
    .filters input[type="search"] { min-width: 100%; }
    .filters select { flex: 1; }
    .slot-grid { grid-template-columns: repeat(2, 1fr); }
    .two-col { grid-template-columns: 1fr; }
    .row2 { grid-template-columns: 1fr; }
    .kv { grid-template-columns: 100px 1fr; }
    .drawer { padding: 18px 16px 40px; }
}

/* ===== ispis (raspored dostave) ===== */
@media print {
    body { background: #fff; font-size: 11pt; }
    .top, .no-print, .toast, #tab-narudzbe { display: none !important; }
    main { padding: 0; max-width: none; }
    .panel { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
    .two-col { grid-template-columns: 1fr; }
    .stop { break-inside: avoid; }
}
