:root {
  --ink: #182234;
  --muted: #657086;
  --line: #dfe4ec;
  --surface: #ffffff;
  --canvas: #f3f5f8;
  --nav: #172033;
  --nav-2: #232e44;
  --accent: #2563eb;
  --accent-soft: #eaf1ff;
  --success: #16855b;
  --success-soft: #e8f7f0;
  --danger: #c33d4b;
  --danger-soft: #fff0f2;
  --warning: #b76b00;
  --warning-soft: #fff5df;
  --shadow: 0 14px 36px rgba(23, 32, 51, .10);
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #10192b 0%, #243450 58%, #e9edf4 58%, #f6f7f9 100%); }
.login-card { width: min(940px, 100%); min-height: 560px; display: grid; grid-template-columns: 1.15fr .85fr; background: var(--surface); box-shadow: 0 26px 80px rgba(0,0,0,.22); overflow: hidden; }
.login-brand { padding: 52px; color: white; background: radial-gradient(circle at 18% 18%, rgba(65, 125, 255, .32), transparent 38%), var(--nav); display: flex; flex-direction: column; justify-content: space-between; }
.brand-mark { width: 54px; height: 54px; border: 1px solid rgba(255,255,255,.25); display: grid; place-items: center; font-weight: 800; font-size: 1.35rem; letter-spacing: -.05em; }
.login-brand h1 { font-size: clamp(2.4rem, 5vw, 4.4rem); line-height: .96; margin: 22px 0 18px; letter-spacing: -.07em; }
.login-brand p { max-width: 420px; color: rgba(255,255,255,.74); line-height: 1.65; }
.login-points { display: grid; gap: 11px; color: rgba(255,255,255,.84); font-size: .92rem; }
.login-point { display: flex; gap: 10px; align-items: center; }
.dot { width: 7px; height: 7px; background: #73a0ff; border-radius: 50%; flex: 0 0 auto; }
.login-form-wrap { padding: 52px 42px; display: flex; flex-direction: column; justify-content: center; }
.login-form-wrap h2 { font-size: 1.75rem; margin: 0 0 10px; letter-spacing: -.03em; }
.login-form-wrap > p { margin: 0 0 30px; color: var(--muted); line-height: 1.5; }
.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field label { font-weight: 700; font-size: .86rem; }
.input, .select, .textarea { width: 100%; border: 1px solid var(--line); background: white; min-height: 44px; padding: 10px 12px; border-radius: 7px; color: var(--ink); outline: none; transition: .18s border, .18s box-shadow; }
.textarea { min-height: 104px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: #8fb0f4; box-shadow: 0 0 0 3px rgba(37,99,235,.10); }
.btn { min-height: 42px; border: 1px solid transparent; padding: 9px 14px; border-radius: 7px; font-weight: 750; display: inline-flex; justify-content: center; align-items: center; gap: 8px; transition: .18s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #1f55c9; }
.btn-dark { background: var(--nav); color: white; }
.btn-light { background: white; color: var(--ink); border-color: var(--line); }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-sm { min-height: 34px; padding: 6px 10px; font-size: .84rem; }
.demo-codes { margin-top: 20px; padding: 14px; background: #f6f8fb; border: 1px solid var(--line); border-radius: 7px; font-size: .82rem; line-height: 1.65; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0,1fr); }
.sidebar { background: var(--nav); color: white; min-height: 100vh; padding: 24px 18px; position: sticky; top: 0; align-self: start; display: flex; flex-direction: column; }
.sidebar-brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 26px; }
.sidebar-brand .brand-mark { width: 40px; height: 40px; font-size: 1rem; }
.sidebar-brand strong { display: block; letter-spacing: -.02em; }
.sidebar-brand span { color: rgba(255,255,255,.58); font-size: .76rem; }
.nav { display: grid; gap: 6px; }
.nav-btn { width: 100%; border: 0; color: rgba(255,255,255,.68); background: transparent; text-align: left; padding: 11px 12px; border-radius: 7px; display: flex; align-items: center; gap: 11px; font-weight: 700; }
.nav-btn:hover, .nav-btn.active { color: white; background: var(--nav-2); }
.nav-icon { width: 18px; text-align: center; opacity: .9; }
.sidebar-user { margin-top: auto; border-top: 1px solid rgba(255,255,255,.10); padding: 18px 8px 0; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #3a65bd; display: grid; place-items: center; font-weight: 850; }
.user-chip strong { display: block; font-size: .88rem; }
.user-chip span { display: block; font-size: .75rem; color: rgba(255,255,255,.55); }
.logout-btn { width: 100%; margin-top: 12px; background: transparent; color: rgba(255,255,255,.65); border: 1px solid rgba(255,255,255,.15); }

.main { min-width: 0; }
.topbar { min-height: 74px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px); }
.topbar-left { display: flex; align-items: center; gap: 14px; }
.menu-toggle { display: none; }
.page-title { margin: 0; font-size: 1.3rem; letter-spacing: -.03em; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.notification-button { position: relative; }
.notification-badge { position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--danger); color: white; display: grid; place-items: center; font-size: .7rem; border: 2px solid white; }
.content { padding: 28px; max-width: 1480px; margin: 0 auto; }

.hero { padding: 28px; background: linear-gradient(115deg, var(--nav) 0%, #28406a 100%); color: white; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 22px; box-shadow: var(--shadow); }
.hero h2 { margin: 0 0 8px; font-size: clamp(1.55rem, 3vw, 2.3rem); letter-spacing: -.04em; }
.hero p { margin: 0; color: rgba(255,255,255,.72); max-width: 700px; line-height: 1.55; }
.hero .btn { background: white; color: var(--nav); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin: 18px 0 28px; }
.stat-card { background: white; border: 1px solid var(--line); padding: 19px; box-shadow: 0 6px 18px rgba(24,34,52,.04); }
.stat-card span { color: var(--muted); font-size: .79rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.stat-card strong { display: block; font-size: 1.85rem; margin-top: 8px; letter-spacing: -.04em; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin: 0 0 14px; }
.section-head h2, .section-head h3 { margin: 0; letter-spacing: -.03em; }
.section-head p { margin: 4px 0 0; color: var(--muted); }

.panel { background: white; border: 1px solid var(--line); box-shadow: 0 7px 22px rgba(24,34,52,.04); }
.panel-head { padding: 17px 19px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.panel-head h3 { margin: 0; font-size: 1rem; }
.panel-body { padding: 19px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }

.order-list { display: grid; gap: 10px; }
.order-card { border: 1px solid var(--line); background: white; padding: 17px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 18px; transition: .18s ease; }
.order-card:hover { border-color: #b9c7dd; box-shadow: 0 10px 24px rgba(24,34,52,.07); transform: translateY(-1px); }
.order-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.order-title-row h3 { margin: 0; font-size: 1rem; }
.order-meta { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: .82rem; }
.order-actions { display: flex; align-items: center; gap: 8px; }
.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 4px 8px; border-radius: 20px; font-size: .73rem; font-weight: 800; border: 1px solid transparent; }
.badge-blue { color: #2153b2; background: var(--accent-soft); }
.badge-green { color: #11704c; background: var(--success-soft); }
.badge-red { color: #a82d3a; background: var(--danger-soft); }
.badge-orange { color: #8a5200; background: var(--warning-soft); }
.badge-gray { color: #596274; background: #eff2f6; }
.empty-state { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty-icon { width: 52px; height: 52px; margin: 0 auto 13px; border: 1px solid var(--line); display: grid; place-items: center; font-size: 1.5rem; background: #f8fafc; }

.upload-zone { border: 1.5px dashed #b9c3d1; background: #f8fafc; padding: 28px; text-align: center; position: relative; }
.upload-zone input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.upload-zone strong { display: block; margin-bottom: 5px; }
.upload-items { display: grid; gap: 10px; margin-top: 14px; }
.upload-item { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0,1.1fr) auto; gap: 10px; align-items: center; border: 1px solid var(--line); padding: 10px; background: white; }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; font-weight: 700; }


.activity-summary { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.activity-summary > div { border: 1px solid var(--line); background: #f8fafc; padding: 13px; }
.activity-summary span { display: block; color: var(--muted); font-size: .76rem; margin-bottom: 5px; }
.activity-summary strong { font-size: 1.35rem; }

.filters { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 15px; }
.filter-btn { border: 1px solid var(--line); background: white; min-height: 36px; padding: 7px 11px; border-radius: 20px; font-size: .82rem; font-weight: 750; color: var(--muted); }
.filter-btn.active { color: #1d4fa8; border-color: #8fb0f4; background: var(--accent-soft); }

.notification-list { display: grid; gap: 8px; }
.notification-item { border: 1px solid var(--line); padding: 14px; display: grid; grid-template-columns: 10px minmax(0,1fr) auto; gap: 11px; align-items: start; background: white; }
.notification-item.unread { border-left: 3px solid var(--accent); }
.notification-dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; margin-top: 5px; }
.notification-item.read .notification-dot { background: #ccd2dc; }
.notification-item strong { display: block; font-size: .88rem; }
.notification-item p { margin: 4px 0 0; color: var(--muted); font-size: .82rem; }

.admin-tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.admin-tab { border: 0; background: transparent; padding: 11px 12px; color: var(--muted); font-weight: 750; border-bottom: 2px solid transparent; white-space: nowrap; cursor: pointer; touch-action: manipulation; }
.admin-tab:hover { color: var(--text); background: rgba(15,23,42,.04); }
.admin-tab:focus-visible { outline: 3px solid rgba(37,99,235,.22); outline-offset: -2px; }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; min-width: 640px; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 11px 9px; font-size: .84rem; }
th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.code-pill { background: #eef1f5; border: 1px solid var(--line); padding: 3px 7px; border-radius: 5px; }
.route-builder { display: grid; grid-template-columns: .85fr 1.15fr; gap: 18px; }
.builder-source, .builder-canvas { border: 1px solid var(--line); min-height: 360px; background: #fbfcfd; padding: 16px; }
.builder-source h4, .builder-canvas h4 { margin: 0 0 12px; }
.builder-card { border: 1px solid var(--line); background: white; padding: 12px; margin-bottom: 9px; }
.builder-card strong { font-size: .87rem; }
.builder-card p { margin: 4px 0 0; color: var(--muted); font-size: .78rem; }
.step-card { border-left: 4px solid var(--accent); background: white; border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 12px; margin-bottom: 9px; display: grid; grid-template-columns: 28px minmax(0,1fr) auto; gap: 10px; align-items: center; }
.step-number { width: 28px; height: 28px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 850; font-size: .78rem; }
.step-actions { display: flex; gap: 5px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; background: #eef2f7; border-radius: 20px; font-size: .74rem; font-weight: 700; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.58); z-index: 100; display: grid; place-items: center; padding: 22px; }
.modal { width: min(1120px, 100%); max-height: 92vh; overflow: hidden; background: white; box-shadow: 0 28px 90px rgba(0,0,0,.30); display: flex; flex-direction: column; min-width: 0; }
.modal-head { position: sticky; top: 0; z-index: 5; background: white; padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-body { padding: 20px; overflow-y: auto; overflow-x: hidden; min-width: 0; }
.close-btn { width: 36px; height: 36px; border: 1px solid var(--line); background: white; border-radius: 50%; }
.order-detail-grid { display: grid; grid-template-columns: minmax(0,1fr) 330px; gap: 18px; min-width: 0; }
.order-detail-grid > *, .file-review-list, .file-review { min-width: 0; }
.file-review-list { display: grid; gap: 11px; }
.file-review { border: 1px solid var(--line); padding: 14px; }
.file-review-head { display: flex; justify-content: space-between; gap: 14px; align-items: start; }
.file-review h4 { margin: 0; font-size: .93rem; word-break: break-word; }
.file-review p { margin: 6px 0 0; color: var(--muted); font-size: .82rem; }
.stamp-history { display: grid; gap: 7px; margin-top: 12px; }
.seal { border: 1px solid var(--line); padding: 9px 10px; background: #fafbfc; display: flex; justify-content: space-between; gap: 10px; }
.seal.approved { border-left: 4px solid var(--success); }
.seal.rejected { border-left: 4px solid var(--danger); }
.seal.observed { border-left: 4px solid var(--warning); }
.seal strong { font-size: .78rem; overflow-wrap: anywhere; }
.seal span { color: var(--muted); font-size: .72rem; overflow-wrap: anywhere; }
.review-controls { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; margin-top: 12px; min-width: 0; }
.review-controls > * { min-width: 0; max-width: 100%; }
.review-controls .full { grid-column: 1 / -1; }
.timeline { display: grid; gap: 0; }
.timeline-step { display: grid; grid-template-columns: 22px 1fr; gap: 10px; min-height: 54px; }
.timeline-line { display: flex; flex-direction: column; align-items: center; }
.timeline-dot { width: 12px; height: 12px; border-radius: 50%; background: #d1d7e1; border: 3px solid white; box-shadow: 0 0 0 1px #d1d7e1; }
.timeline-step.done .timeline-dot { background: var(--success); box-shadow: 0 0 0 1px var(--success); }
.timeline-step.current .timeline-dot { background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.timeline-stem { width: 1px; flex: 1; background: var(--line); }
.timeline-step:last-child .timeline-stem { display: none; }
.timeline-copy strong { display: block; font-size: .82rem; }
.timeline-copy span { color: var(--muted); font-size: .74rem; }
.detail-actions { display: grid; gap: 8px; margin-top: 16px; }

.toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 250; display: grid; gap: 8px; width: min(360px, calc(100vw - 40px)); }
.toast { background: var(--nav); color: white; padding: 13px 14px; box-shadow: var(--shadow); animation: toast-in .2s ease; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

@media (max-width: 980px) {
  .login-card { grid-template-columns: 1fr; }
  .login-brand { min-height: 260px; padding: 34px; }
  .login-brand h1 { font-size: 3rem; }
  .login-points { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 80; width: 248px; inset: 0 auto 0 0; transform: translateX(-100%); transition: .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .stats-grid, .activity-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .order-detail-grid, .route-builder { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .login-screen { padding: 0; }
  .login-card { min-height: 100vh; }
  .login-brand { min-height: 210px; }
  .login-form-wrap { padding: 30px 24px; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
  .hero { grid-template-columns: 1fr; padding: 22px; }
  .stats-grid, .activity-summary, .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .order-card { grid-template-columns: 1fr; }
  .order-actions { justify-content: stretch; }
  .order-actions .btn { width: 100%; }
  .upload-item { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { width: 100%; max-height: 96vh; }
  .modal-body { padding: 15px; }
  .file-review-head { flex-direction: column; align-items: stretch; }
  .file-review-head .btn { width: 100%; }
  .review-controls { grid-template-columns: 1fr; }
  .review-controls .full { grid-column: auto; }
}

.flow-alert { margin-bottom: 16px; border: 1px solid var(--line); background: #f8fafc; padding: 13px 14px; display: grid; gap: 4px; }
.flow-alert strong { font-size: .88rem; }
.flow-alert span { color: var(--muted); font-size: .82rem; line-height: 1.45; }
.flow-alert.warning { border-left: 4px solid var(--warning); background: var(--warning-soft); }
.flow-alert.danger { border-left: 4px solid var(--danger); background: var(--danger-soft); }
.seal.superseded { opacity: .58; border-style: dashed; }
.admin-recovery { margin-top: 10px; border: 1px solid #f0c5ca; background: #fff7f8; padding: 12px; display: grid; gap: 9px; }
.admin-recovery > strong { font-size: .84rem; }
.admin-recovery p { margin: 0; }
.recovery-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; }
@media (max-width: 680px) { .recovery-actions { grid-template-columns: 1fr; } }
