:root {
  color-scheme: light;
  --graphite-950: #151d22;
  --graphite-900: #202a31;
  --graphite-800: #2d383f;
  --graphite-700: #445159;
  --gray-50: #f7f9fa;
  --gray-100: #eef2f4;
  --gray-200: #dde4e8;
  --gray-300: #cbd4d9;
  --gray-500: #74818a;
  --white: #ffffff;
  --orange: #d84b00;
  --orange-strong: #bf3f00;
  --orange-soft: #fff1e8;
  --blue: #287bd3;
  --blue-soft: #eaf4ff;
  --amber: #d69712;
  --amber-soft: #fff7dc;
  --green: #2f9b4d;
  --green-soft: #ebf8ee;
  --red: #c73b3b;
  --red-soft: #fff0f0;
  --shadow-sm: 0 1px 3px rgba(21, 29, 34, .10), 0 1px 2px rgba(21, 29, 34, .06);
  --shadow-md: 0 14px 38px rgba(21, 29, 34, .16);
  --radius: 10px;
  --sidebar: 220px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; margin: 0; }
body { background: var(--gray-100); color: var(--graphite-950); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 480px) minmax(0, 1fr);
  background: var(--white);
}
.auth-panel { padding: clamp(36px, 8vw, 96px); display: flex; flex-direction: column; justify-content: center; }
.auth-visual { position: relative; overflow: hidden; background: linear-gradient(145deg, var(--graphite-950), #34434c); color: white; padding: 8vw; display: flex; align-items: flex-end; }
.auth-visual::before { content: ""; position: absolute; inset: 8% -20% auto 25%; height: 55%; transform: rotate(-7deg); background: linear-gradient(90deg, transparent, rgba(255,255,255,.07)); border-block: 1px solid rgba(255,255,255,.12); }
.auth-copy { position: relative; max-width: 680px; }
.auth-copy h2 { font-size: clamp(32px, 4vw, 60px); margin: 0 0 18px; line-height: 1.02; }
.auth-copy p { color: #d7e0e4; font-size: 18px; max-width: 580px; }

.brand { display: inline-flex; flex-direction: column; line-height: 1; letter-spacing: -.05em; font-weight: 800; font-size: 29px; }
.brand small { margin-top: 4px; font-size: 7px; letter-spacing: .08em; font-weight: 600; }
.brand-dark { color: var(--graphite-950); margin-bottom: 38px; }
.eyebrow { color: var(--orange); text-transform: uppercase; letter-spacing: .12em; font-weight: 750; font-size: 12px; }
.auth-panel h1 { margin: 8px 0 10px; font-size: 30px; letter-spacing: -.03em; }
.muted { color: var(--gray-500); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; color: #e7ecef; background: linear-gradient(180deg, var(--graphite-900), var(--graphite-950)); padding: 24px 14px 18px; display: flex; flex-direction: column; z-index: 20; }
.sidebar .brand { color: white; margin: 4px 14px 32px; }
.nav { display: grid; gap: 4px; }
.nav-button { width: 100%; min-height: 44px; border: 0; border-left: 3px solid transparent; border-radius: 6px; background: transparent; color: #cad3d8; display: flex; align-items: center; gap: 12px; padding: 0 13px; text-align: left; }
.nav-button:hover { color: white; background: rgba(255,255,255,.05); }
.nav-button.active { color: white; border-left-color: var(--orange); background: rgba(255,255,255,.09); }
.nav-button svg { width: 19px; height: 19px; stroke-width: 1.8; }
.sidebar-spacer { flex: 1; }
.sidebar-user { border-top: 1px solid rgba(255,255,255,.1); padding: 15px 12px 0; font-size: 13px; color: #bac5cb; }
.sidebar-user strong { display: block; color: white; margin-bottom: 3px; }

.workspace { min-width: 0; }
.topbar { height: 66px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; gap: 18px; padding: 0 24px; position: sticky; top: 0; z-index: 15; backdrop-filter: blur(10px); }
.global-search { width: min(460px, 45vw); position: relative; }
.global-search input { width: 100%; height: 38px; border: 1px solid var(--gray-200); border-radius: 7px; padding: 0 14px 0 39px; background: var(--gray-50); }
.global-search svg { position: absolute; left: 12px; top: 10px; width: 18px; color: var(--gray-500); }
.topbar-spacer { flex: 1; }
.topbar-service { color: var(--gray-700); font-size: 13px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--graphite-800); color: white; font-size: 12px; font-weight: 750; }
.mobile-title { display: none; }

.main { width: min(1500px, 100%); margin: 0 auto; padding: 26px clamp(18px, 3vw, 42px) 60px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-header h1 { font-size: 27px; letter-spacing: -.035em; margin: 0; }
.page-header p { margin: 5px 0 0; color: var(--gray-500); }
.header-actions { display: flex; gap: 9px; flex-wrap: wrap; }

.button { min-height: 40px; border: 1px solid var(--gray-300); background: var(--white); color: var(--graphite-900); border-radius: 7px; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 680; text-decoration: none; transition: .15s ease; }
.button:hover { border-color: var(--graphite-700); transform: translateY(-1px); }
.button.primary { color: white; border-color: var(--orange); background: linear-gradient(#e75a0e, var(--orange)); box-shadow: 0 4px 10px rgba(216,75,0,.18); }
.button.primary:hover { background: var(--orange-strong); }
.button.danger { color: var(--red); border-color: #e6b9b9; background: var(--red-soft); }
.button.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.button.icon { width: 40px; padding: 0; }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--white); border: 1px solid #e8ecef; border-radius: var(--radius); min-height: 88px; padding: 17px 20px; display: flex; align-items: center; gap: 15px; box-shadow: var(--shadow-sm); }
.stat-icon { width: 42px; height: 42px; border-radius: 9px; display: grid; place-items: center; color: var(--graphite-800); background: var(--gray-100); }
.stat-icon.orange { color: var(--orange); background: var(--orange-soft); }
.stat-icon.blue { color: var(--blue); background: var(--blue-soft); }
.stat-icon.green { color: var(--green); background: var(--green-soft); }
.stat-label { font-size: 12px; color: var(--gray-500); font-weight: 680; }
.stat-value { font-size: 25px; font-weight: 780; line-height: 1.1; }

.panel { background: var(--white); border: 1px solid #e3e8eb; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-header { padding: 16px 18px; border-bottom: 1px solid var(--gray-200); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-header h2, .panel-header h3 { margin: 0; font-size: 16px; }
.panel-body { padding: 18px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; }
.stack { display: grid; gap: 16px; }

.kanban { display: grid; grid-template-columns: repeat(5, minmax(225px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.kanban-column { min-width: 225px; background: #e8edf0; border-radius: 8px; padding: 8px; }
.kanban-column[data-state="V_PRACI"] { background: #e6f0fb; }
.kanban-column[data-state="CEKA_NA_DILY"] { background: #fbf2d9; }
.kanban-column[data-state="K_PREDANI"] { background: #e7f4ea; }
.kanban-title { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 760; padding: 4px 5px 10px; text-transform: uppercase; letter-spacing: .035em; }
.kanban-title::before { content: ""; width: 4px; height: 18px; border-radius: 5px; background: var(--gray-500); }
.kanban-column[data-state="V_PRACI"] .kanban-title::before { background: var(--blue); }
.kanban-column[data-state="CEKA_NA_DILY"] .kanban-title::before { background: var(--amber); }
.kanban-column[data-state="K_PREDANI"] .kanban-title::before { background: var(--green); }
.count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: rgba(255,255,255,.75); display: grid; place-items: center; color: var(--gray-700); }
.job-card { display: block; width: 100%; border: 1px solid #d9e0e4; border-radius: 7px; background: white; color: inherit; padding: 12px; margin-bottom: 7px; text-align: left; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.job-card:hover { border-color: #aab7bf; box-shadow: var(--shadow-sm); }
.job-card strong { display: block; font-size: 13px; margin-bottom: 3px; }
.job-card .vehicle { font-weight: 720; font-size: 13px; }
.job-card .subject { color: var(--gray-700); margin: 6px 0; font-size: 12px; }
.job-card footer { display: flex; justify-content: space-between; gap: 8px; color: var(--gray-500); font-size: 11px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 12px; text-align: left; color: var(--gray-500); font-size: 11px; text-transform: uppercase; letter-spacing: .045em; border-bottom: 1px solid var(--gray-200); background: var(--gray-50); }
td { padding: 12px; border-bottom: 1px solid var(--gray-200); vertical-align: middle; font-size: 13px; }
tbody tr:hover { background: #fafcfd; }
tbody tr:last-child td { border-bottom: 0; }
.row-link { cursor: pointer; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 25px; padding: 0 9px; border-radius: 999px; font-size: 11px; font-weight: 730; color: var(--graphite-800); background: var(--gray-100); white-space: nowrap; }
.badge.blue { color: #1661ad; background: var(--blue-soft); }
.badge.amber { color: #8a5e00; background: var(--amber-soft); }
.badge.green { color: #247a3d; background: var(--green-soft); }
.badge.orange { color: var(--orange-strong); background: var(--orange-soft); }
.badge.red { color: var(--red); background: var(--red-soft); }

.form { display: grid; gap: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 720; color: var(--graphite-700); }
.field input, .field select, .field textarea { width: 100%; min-height: 41px; border: 1px solid var(--gray-300); background: white; border-radius: 7px; padding: 9px 11px; color: var(--graphite-950); }
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 3px solid rgba(40,123,211,.15); border-color: var(--blue); }
.check { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.check input { width: 18px; height: 18px; accent-color: var(--orange); }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 4px; }
.help { color: var(--gray-500); font-size: 12px; line-height: 1.45; }

.modal { width: min(680px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; border: 0; border-radius: 12px; box-shadow: var(--shadow-md); }
.modal::backdrop { background: rgba(15, 22, 27, .55); backdrop-filter: blur(2px); }
.modal-header { padding: 18px 21px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--gray-200); }
.modal-header h2 { margin: 0; font-size: 19px; }
.modal-body { padding: 20px 21px 24px; max-height: calc(100vh - 110px); overflow-y: auto; }
.close { border: 0; background: transparent; font-size: 24px; color: var(--gray-500); }

.detail-head { background: white; border-bottom: 1px solid var(--gray-200); margin: -26px calc(clamp(18px, 3vw, 42px) * -1) 24px; padding: 22px clamp(18px, 3vw, 42px); }
.detail-head-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.detail-head h1 { margin: 0; font-size: 24px; }
.detail-tabs { display: flex; gap: 22px; margin-top: 20px; font-size: 13px; }
.detail-tabs span { padding-bottom: 10px; border-bottom: 2px solid transparent; }
.detail-tabs .active { color: var(--orange); border-color: var(--orange); font-weight: 720; }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--gray-200); }
.task input { width: 19px; height: 19px; accent-color: var(--orange); }
.task.done span { text-decoration: line-through; color: var(--gray-500); }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.metric { padding: 13px; background: var(--gray-50); border-radius: 8px; }
.metric small { color: var(--gray-500); }
.metric strong { display: block; margin-top: 3px; }
.timeline { display: grid; gap: 0; }
.timeline-item { position: relative; padding: 0 0 18px 22px; border-left: 2px solid var(--gray-200); margin-left: 5px; }
.timeline-item::before { content: ""; position: absolute; left: -6px; top: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--orange); border: 2px solid white; }
.timeline-item time { display: block; color: var(--gray-500); font-size: 11px; margin-top: 3px; }
.empty { min-height: 150px; display: grid; place-items: center; text-align: center; color: var(--gray-500); padding: 25px; }

.toast-region { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 100; }
.toast { min-width: 280px; max-width: 430px; color: white; background: var(--graphite-900); border-left: 4px solid var(--green); border-radius: 8px; box-shadow: var(--shadow-md); padding: 13px 15px; animation: toast-in .2s ease-out; }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.skeleton { min-height: 100px; border-radius: 8px; background: linear-gradient(90deg,#eef2f4 25%,#f8fafb 50%,#eef2f4 75%); background-size: 200% 100%; animation: loading 1.2s infinite; }
@keyframes loading { to { background-position: -200% 0; } }

.public-page { min-height: 100vh; background: var(--gray-100); }
.public-top { height: 88px; background: var(--graphite-900); color: white; display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 760px)/2)); }
.public-content { max-width: 760px; margin: 0 auto; padding: 30px 18px 70px; }
.public-card { background: white; border: 1px solid var(--gray-200); border-radius: 12px; padding: 21px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.public-hero { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.public-hero h1 { margin: 0 0 5px; font-size: 23px; }
.public-action { width: 100%; min-height: 52px; font-size: 16px; }
.scanner video { width: 100%; min-height: 180px; max-height: 360px; object-fit: cover; background: var(--graphite-950); border-radius: 9px; margin-bottom: 12px; }

.mobile-nav { display: none; }

.admin-shell { min-height: 100vh; }
.admin-topbar { min-height: 70px; padding: 12px clamp(18px, 4vw, 56px); color: white; background: var(--graphite-900); display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.admin-user { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.admin-main { width: min(1500px, 100%); margin: 0 auto; padding: 34px clamp(18px, 4vw, 56px) 70px; }
.domain-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border: 1px solid var(--gray-300); border-radius: 7px; overflow: hidden; }
.domain-field input { border: 0; border-radius: 0; }
.domain-field span { padding: 0 11px; color: var(--gray-500); font-size: 13px; }

@media (max-width: 1050px) {
  :root { --sidebar: 78px; }
  .sidebar .brand { margin-inline: auto; }
  .sidebar .brand small, .nav-button span, .sidebar-user { display: none; }
  .nav-button { justify-content: center; padding: 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .auth-layout { display: block; }
  .auth-visual { display: none; }
  .auth-panel { min-height: 100vh; padding: 30px 22px; }
  .app-shell { display: block; }
  .sidebar { display: none; }
  .topbar { height: 64px; padding: 0 16px; background: var(--graphite-900); color: white; }
  .global-search, .topbar-service { display: none; }
  .mobile-title { display: block; font-size: 17px; font-weight: 760; }
  .main { padding: 20px 14px 90px; }
  .page-header { align-items: flex-start; }
  .page-header h1 { font-size: 23px; }
  .header-actions .button:not(.primary):not(.mobile-visible) { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { min-height: 75px; padding: 12px; }
  .stat-icon { display: none; }
  .stat-value { font-size: 22px; }
  .kanban { grid-template-columns: 86vw 86vw 86vw 86vw 86vw; scroll-snap-type: x mandatory; }
  .kanban-column { scroll-snap-align: start; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .detail-head { margin: -20px -14px 18px; padding: 18px 14px; }
  .metric-grid { grid-template-columns: 1fr; }
  .mobile-nav { position: fixed; inset: auto 0 0; height: 68px; padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(255,255,255,.97); border-top: 1px solid var(--gray-200); z-index: 30; backdrop-filter: blur(10px); }
  .mobile-nav button { border: 0; background: transparent; color: var(--gray-500); display: grid; place-items: center; align-content: center; gap: 3px; font-size: 10px; }
  .mobile-nav button.active { color: var(--orange); }
  .mobile-nav svg { width: 21px; height: 21px; }
  .table-wrap.mobile-cards table, .table-wrap.mobile-cards thead, .table-wrap.mobile-cards tbody, .table-wrap.mobile-cards tr, .table-wrap.mobile-cards td { display: block; }
  .table-wrap.mobile-cards thead { display: none; }
  .table-wrap.mobile-cards tr { padding: 13px; border-bottom: 1px solid var(--gray-200); }
  .table-wrap.mobile-cards td { padding: 3px 0; border: 0; }
  .public-top { padding: 0 18px; height: 78px; }
  .public-content { padding-top: 18px; }
  .public-hero { display: grid; }
  .admin-topbar { align-items: flex-start; }
  .admin-user span { display: none; }
  .admin-main { padding: 22px 14px 60px; }
  .domain-field { grid-template-columns: 1fr; }
  .domain-field span { padding: 0 11px 10px; }
}
