:root {
  --brand: #0063CB; --brand-dark: #004fa3; --brand-soft: #e6f0fb;
  --ink-dark: #1a1f2e; --ink: #2a2f3a; --ink-soft: #454D58; --ink-muted: #8a92a0;
  --bg: #f5f7fb; --surface: #fff; --line: #e4e8ef; --line-strong: #cfd5df;
  --status-ordered-bg: #fef3d7; --status-ordered-text: #7a5a10; --status-ordered-dot: #c89730;
  --status-received-bg: #d4e6f5; --status-received-text: #1f4a7a; --status-received-dot: #4a7ba8;
  --status-received-row: #ecf3fa; --status-received-row-hover: #dceaf6;
  --status-cancelled-bg: #f0d4d4; --status-cancelled-text: #7a1f1f; --status-cancelled-dot: #b54a4a;
  --status-cancelled-row: #fbeaea;
  --status-poslan-text: #1e7a3a; --status-poslan-dot: #34a853;
  --warn-orange: #d97706; --warn-orange-bg: #fff3d9; --warn-orange-row: #fff7e6;
  --warn-red: #c4262e; --warn-red-bg: #ffe0e0; --warn-red-row: #fff0f0;
  --soft-deleted: #f0f0f0;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); font-family: 'Inter', sans-serif; color: var(--ink); font-size: 14px; line-height: 1.5; min-height: 100vh; }

/* ===== LOGIN ===== */
.login-screen {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #f0f4fb 0%, #e6f0fb 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 5000; padding: 20px;
}
.login-card {
  background: var(--surface); border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 99, 203, 0.15), 0 4px 12px rgba(0,0,0,0.05);
  padding: 40px 36px; max-width: 420px; width: 100%;
}
.login-logo { display: flex; justify-content: center; margin-bottom: 24px; }
.login-logo img { height: 50px; }
.login-title { font-family: 'Fraunces', serif; font-size: 22px; font-weight: 600; text-align: center; color: var(--ink-dark); margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--brand); font-size: 12px; font-weight: 600; letter-spacing: 0.5px; margin-bottom: 28px; }
.login-field { margin-bottom: 14px; }
.login-label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--ink-muted); margin-bottom: 5px; }
.login-input { width: 100%; padding: 11px 14px; border: 1px solid var(--line-strong); border-radius: 10px; font-family: 'Inter', sans-serif; font-size: 14px; outline: none; transition: all 0.15s; }
.login-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0, 99, 203, 0.1); }
.login-btn { width: 100%; padding: 12px; background: var(--brand); color: white; border: none; border-radius: 10px; font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 8px; transition: background 0.15s; }
.login-btn:hover { background: var(--brand-dark); }
.login-error { background: var(--warn-red-bg); color: var(--warn-red); padding: 10px 14px; border-radius: 8px; font-size: 12px; margin-bottom: 14px; display: none; }
.login-error.visible { display: block; }
.login-hint { text-align: center; font-size: 11px; color: var(--ink-muted); margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.login-hint code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--brand-dark); }

/* ===== APP ===== */
.app { display: none; }
.app.visible { display: block; }

.mockup-banner { background: linear-gradient(90deg, #fff7e0, #ffe9b8); border-bottom: 1px solid #f0c878; padding: 8px 32px; font-size: 12px; color: #6b4a1a; text-align: center; font-weight: 500; }
.mockup-banner strong { font-weight: 700; }

.header { background: var(--surface); border-bottom: 1px solid var(--line); padding: 14px 32px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; box-shadow: 0 1px 0 rgba(0,0,0,0.02); }
.brand { display: flex; align-items: center; gap: 16px; }
.brand-logo { height: 38px; width: auto; }
.brand-divider { width: 1px; height: 36px; background: var(--line-strong); }
.app-name { display: flex; flex-direction: column; line-height: 1.15; }
.app-title { font-family: 'Fraunces', serif; font-size: 18px; font-weight: 600; letter-spacing: -0.3px; color: var(--ink-dark); }
.app-subtitle { font-size: 11px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }
.app-client { font-size: 12px; color: var(--brand); font-weight: 600; letter-spacing: 0.3px; margin-top: 1px; }

.header-actions { display: flex; align-items: center; gap: 24px; }
.btn-export { padding: 8px 14px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; transition: all 0.15s; }
.btn-export:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }

.user-bar { display: flex; align-items: center; gap: 16px; font-size: 13px; }
.user-info { text-align: right; line-height: 1.3; }
.user-name { font-weight: 600; color: var(--ink); }
.user-role { color: var(--ink-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.btn-logout { padding: 7px 12px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 6px; font-size: 12px; cursor: pointer; color: var(--ink-soft); }
.btn-logout:hover { color: var(--warn-red); border-color: var(--warn-red); }

.stats-bar { margin: 24px 32px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; position: relative; overflow: hidden; }
.stat.alert-orange { border-color: var(--warn-orange); background: linear-gradient(to right, var(--warn-orange-bg) 0%, var(--surface) 80%); }
.stat.alert-red { border-color: var(--warn-red); background: linear-gradient(to right, var(--warn-red-bg) 0%, var(--surface) 80%); }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--ink-muted); font-weight: 600; }
.stat-value { font-family: 'Fraunces', serif; font-size: 32px; font-weight: 600; letter-spacing: -1px; margin-top: 4px; line-height: 1; color: var(--ink-dark); }
.stat.alert-orange .stat-value { color: var(--warn-orange); }
.stat.alert-red .stat-value { color: var(--warn-red); }
.stat-value-text { font-family: 'Fraunces', serif; font-size: 20px; font-weight: 600; letter-spacing: -0.5px; margin-top: 8px; line-height: 1.1; color: var(--ink-dark); }
.stat-trend { font-size: 11px; color: var(--ink-muted); margin-top: 6px; font-family: 'JetBrains Mono', monospace; }
.stat::after { content: ''; position: absolute; top: 0; right: 0; width: 80px; height: 80px; background: radial-gradient(circle, rgba(0,99,203,0.05) 0%, transparent 70%); }

.toolbar { padding: 0 32px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.page-title { font-family: 'Fraunces', serif; font-size: 26px; font-weight: 600; letter-spacing: -0.8px; margin-right: auto; color: var(--ink-dark); }
.page-title .count { font-size: 13px; color: var(--ink-muted); font-family: 'JetBrains Mono', monospace; font-weight: 400; margin-left: 12px; vertical-align: middle; }
.search-box { position: relative; width: 260px; }
.search-box input { width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; font-family: 'Inter', sans-serif; font-size: 13px; outline: none; transition: all 0.15s; }
.search-box.has-filter input { padding-right: 32px; }
.search-box input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,99,203,0.1); }
.search-box::before { content: "⌕"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-muted); font-size: 16px; }
.search-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--line); color: var(--ink-soft); font-size: 14px; line-height: 1; text-decoration: none; cursor: pointer; transition: all 0.15s; }
.search-clear:hover { background: var(--warn-red); color: white; }

.opto-filter { display: flex; align-items: center; gap: 6px; }
.opto-filter select { padding: 8px 12px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; font-family: 'Inter', sans-serif; font-size: 13px; outline: none; cursor: pointer; }
.opto-filter select:focus { border-color: var(--brand); }

.btn { padding: 9px 16px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); color: white; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); color: white; border-color: var(--brand-dark); }

.filters { padding: 0 32px 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.filter-chip { padding: 6px 14px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.15s; display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.filter-chip:hover { border-color: var(--brand); }
.filter-chip.active { background: var(--ink-dark); color: white; border-color: var(--ink-dark); }
.filter-chip .num { background: rgba(0,0,0,0.08); padding: 1px 7px; border-radius: 999px; font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.filter-chip.active .num { background: rgba(255,255,255,0.2); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-amber { background: var(--status-ordered-dot); }
.dot-blue { background: var(--status-received-dot); }
.dot-red { background: var(--status-cancelled-dot); }
.dot-orange { background: var(--warn-orange); }
.dot-deepred { background: var(--warn-red); }
.dot-grey { background: #999; }
.dot-green { background: var(--status-poslan-dot); }

.table-wrap { margin: 0 32px 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.03); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 1400px; }
thead { background: #fafbfd; border-bottom: 1px solid var(--line); }
th { text-align: left; padding: 13px 14px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.7px; color: var(--ink-muted); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background 0.1s; position: relative; }
tbody tr:hover { background: #fafbfd; }
tbody tr:last-child td { border-bottom: none; }

tr.status-received { background: var(--status-received-row); }
tr.status-received:hover { background: var(--status-received-row-hover); }
tr.status-cancelled { background: var(--status-cancelled-row); opacity: 0.65; }
tr.status-cancelled td { text-decoration: line-through; color: var(--status-cancelled-text); }
tr.soft-deleted { background: var(--soft-deleted); opacity: 0.5; }
tr.soft-deleted td { text-decoration: line-through; color: #888; }

tr.late-orange { background: var(--warn-orange-row); }
tr.late-orange td:first-child { position: relative; }
tr.late-orange td:first-child::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--warn-orange); }
tr.late-orange:hover { background: #fff0c8; }

tr.late-red { background: var(--warn-red-row); }
tr.late-red td:first-child { position: relative; }
tr.late-red td:first-child::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--warn-red); }
tr.late-red:hover { background: #ffe0e0; }

.cust-name { font-weight: 600; color: var(--ink-dark); font-size: 15px; line-height: 1.35; }
.cust-phone { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--ink-soft); }
.date { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--ink-soft); }
.product { font-size: 13px; color: var(--ink); }

.diopter { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--ink); line-height: 1.5; white-space: nowrap; font-weight: 500; }
.diopter-row { display: block; }
.eye-label { display: inline-block; width: 18px; font-weight: 700; color: var(--brand); font-size: 12px; letter-spacing: 0.3px; }

.add-value { font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 600; color: var(--brand-dark); line-height: 1.4; }
.add-empty { color: var(--ink-muted); font-size: 11px; }

.maker { font-size: 12px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.maker-distrib { font-size: 10px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.4px; margin-top: 2px; }

.opto-name { font-weight: 600; color: var(--brand-dark); font-size: 12px; }

.vrsta { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.vrsta-proba { background: #ede4f5; color: #5a3a82; }
.vrsta-narudzba { background: var(--brand-soft); color: var(--brand-dark); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap; }
.badge-amber { background: var(--status-ordered-bg); color: var(--status-ordered-text); }
.badge-blue { background: var(--status-received-bg); color: var(--status-received-text); }
.badge-red { background: var(--status-cancelled-bg); color: var(--status-cancelled-text); }

.late-marker { display: inline-block; margin-left: 6px; font-weight: 700; font-size: 12px; cursor: help; }
.late-marker.orange { color: var(--warn-orange); }
.late-marker.red { color: var(--warn-red); }

/* ===== C-7b: Status + Mail mergeani u jedan stack ===== */
.status-cell-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.status-subtitle { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; cursor: pointer; }
.status-subtitle:hover { text-decoration: underline; }
.status-subtitle-poslan { color: var(--status-poslan-text); display: inline-flex; align-items: center; gap: 4px; }
.status-subtitle-failed { color: var(--status-cancelled-text); }

/* ===== CONTEXT MENU ===== */
.context-menu { position: fixed; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.06); padding: 6px; min-width: 220px; z-index: 1000; display: none; font-size: 13px; }
.context-menu.visible { display: block; animation: fadeIn 0.12s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.menu-label { padding: 8px 12px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--ink-muted); font-weight: 600; }
.menu-item { padding: 8px 12px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 10px; transition: background 0.1s; }
.menu-item:hover { background: var(--brand-soft); }
.menu-item.danger { color: var(--status-cancelled-text); }
.menu-item.danger:hover { background: var(--status-cancelled-row); }
.menu-divider { height: 1px; background: var(--line); margin: 4px 0; }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(20, 25, 40, 0.5); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 2000; padding: 20px; }
.modal-overlay.visible { display: flex; animation: fadeIn 0.15s; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,0.25); max-width: 820px; width: 100%; max-height: 92vh; overflow-y: auto; }
.modal-header { padding: 20px 28px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-family: 'Fraunces', serif; font-size: 22px; font-weight: 600; letter-spacing: -0.5px; color: var(--ink-dark); }
.modal-close { width: 32px; height: 32px; border-radius: 8px; border: none; background: transparent; font-size: 20px; cursor: pointer; color: var(--ink-muted); display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: var(--bg); color: var(--ink); }
.modal-body { padding: 24px 28px; }

.form-section { margin-bottom: 20px; }
.form-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--brand); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--brand-soft); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field-full { grid-column: 1 / -1; }
.form-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--ink-muted); }
.form-input, .form-select { padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 8px; font-family: 'Inter', sans-serif; font-size: 13px; background: var(--surface); color: var(--ink); outline: none; transition: all 0.15s; }
.form-input:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,99,203,0.1); }
.form-select:disabled { background: #f5f6f9; color: var(--ink-muted); cursor: not-allowed; }

.diopter-grid { display: grid; grid-template-columns: 60px repeat(4, 1fr); gap: 8px; align-items: center; }
.diopter-grid-label { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--brand); font-size: 13px; }
.cyl-row { display: flex; gap: 4px; }
.cyl-select { flex: 1; }
.cyl-custom { width: 80px; display: none; }
.cyl-custom.visible { display: block; }

.modal-footer { padding: 18px 28px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.product-preview { background: var(--brand-soft); border: 1px solid #c5dcf2; border-radius: 8px; padding: 10px 14px; font-size: 12px; color: var(--brand-dark); display: none; margin-top: 12px; }
.product-preview.visible { display: block; }
.product-preview-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; margin-bottom: 4px; }
.product-preview-mail { font-family: 'JetBrains Mono', monospace; font-size: 11px; margin-top: 6px; color: var(--brand); }

.pw-modal { max-width: 420px; }

.toast { position: fixed; bottom: 24px; right: 24px; background: var(--ink-dark); color: white; padding: 12px 20px; border-radius: 10px; font-size: 13px; box-shadow: 0 12px 32px rgba(0,0,0,0.2); display: flex; align-items: center; gap: 10px; z-index: 3000; transform: translateY(100px); opacity: 0; transition: all 0.25s ease; }
.toast.visible { transform: translateY(0); opacity: 1; }
.toast .check { width: 18px; height: 18px; background: var(--status-received-dot); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: bold; }

[data-tip] { position: relative; }
[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--ink-dark); color: white; padding: 6px 10px; border-radius: 6px; font-size: 11px; white-space: nowrap; margin-bottom: 6px; font-family: 'Inter', sans-serif; font-weight: 500; letter-spacing: 0; text-transform: none; z-index: 100; pointer-events: none; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }

.footer { text-align: center; padding: 24px 32px 32px; font-size: 11px; color: var(--ink-muted); }
.footer strong { color: var(--brand); font-weight: 600; }

@media (max-width: 1100px) { .stats-bar { grid-template-columns: repeat(2, 1fr); } }
/* ===== PAGINATION (Faza 4b) ===== */
.pagination { display: flex; gap: 4px; justify-content: center; padding: 16px 32px 24px; flex-wrap: wrap; }
.pagination a, .pagination .current, .pagination .ellipsis, .pagination .disabled {
  padding: 8px 13px; min-width: 38px; text-align: center;
  border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 8px; font-size: 13px; text-decoration: none; color: var(--ink);
  font-family: 'Inter', sans-serif;
}
.pagination a:hover { border-color: var(--brand); color: var(--brand); }
.pagination .current { background: var(--brand); color: white; border-color: var(--brand); font-weight: 600; }
.pagination .ellipsis { color: var(--ink-muted); border-color: transparent; cursor: default; }
.pagination .disabled { color: var(--ink-muted); border-color: var(--line); cursor: not-allowed; opacity: 0.6; }

/* ===== NAPOMENA ROW (sub-row ispod glavne narudžbe) ===== */
tr.napomena-row td { padding: 0 14px 10px 14px; border-bottom: 1px solid var(--line); }
.napomena-text { font-size: 11px; color: var(--ink-soft); font-style: italic; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }

/* ===== LOGOUT FORM (reset default form margins) ===== */
.logout-form { margin: 0; }

/* ===== AUTO-MAPPING SIGNAL (Faza 4b.3.A) ===== */
.maker.inferred { color: var(--ink-muted); font-style: italic; }
