:root {
  --bg: #fafaf7;
  --bg-card: #ffffff;
  --bg-subtle: #f4f3ee;
  --border: #e8e6df;
  --border-strong: #d4d1c7;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --text-soft: #8e8e8e;
  --accent: #c8102e;
  --accent-dark: #a00d24;
  --success: #2d6a4f;
  --warning: #c47f17;
  --danger: #b00020;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* APP LAYOUT */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  padding: 8px 12px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.brand-name {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.brand-name span { color: var(--accent); }
.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
}
.nav-item:hover { background: var(--bg-subtle); color: var(--text); }
.nav-item.active { background: var(--text); color: white; }
.nav-item svg { width: 16px; height: 16px; }
.nav-section {
  font-size: 10px;
  color: var(--text-soft);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 16px 12px 8px;
  font-weight: 600;
}
.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c8102e, #6b1818);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}
.user-info { font-size: 12px; line-height: 1.3; }
.user-info .name { font-weight: 600; }
.user-info .role { color: var(--text-muted); font-size: 11px; }
.sidebar-footer a.logout {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 11px;
}
.sidebar-footer a.logout:hover { color: var(--accent); }

/* MAIN */
.main { flex: 1; padding: 32px 40px; max-width: 1400px; }
.header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 32px; }
.page-title {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 28px; font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.15; margin-bottom: 6px;
}
.page-subtitle { color: var(--text-muted); font-size: 14px; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* STATS */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; }
.stat-label {
  font-size: 11px; color: var(--text-muted);
  letter-spacing: 0.06em; text-transform: uppercase;
  font-weight: 600; margin-bottom: 8px;
}
.stat-value {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 26px; font-weight: 700; line-height: 1; letter-spacing: -0.02em;
}
.stat-meta { font-size: 12px; color: var(--text-soft); margin-top: 4px; }
.stat-meta.positive { color: var(--success); }

/* FILTER BAR */
.filter-bar {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
  border-bottom: none;
  flex-wrap: wrap;
}
.search { flex: 1; min-width: 240px; display: flex; align-items: center; gap: 8px; background: var(--bg-subtle); padding: 8px 12px; border-radius: 6px; border: 1px solid transparent; transition: all 0.15s; }
.search:focus-within { border-color: var(--border-strong); background: white; }
.search input { border: none; background: transparent; outline: none; flex: 1; font-family: inherit; font-size: 13px; }
.search svg { width: 14px; height: 14px; color: var(--text-muted); }
.chip { padding: 6px 12px; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 6px; font-size: 12px; font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: all 0.15s; }
.chip:hover { background: white; }
.chip.active { background: var(--text); color: white; border-color: var(--text); }

/* TABLE */
.table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: 0 0 10px 10px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  user-select: none;
}
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--text); background: var(--border); }
th.sortable.active { color: var(--text); }
th .sort-ind { display: inline-block; width: 10px; opacity: 0.5; font-size: 9px; margin-left: 2px; }
th.sortable.active .sort-ind { opacity: 1; }
td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,0,0,0.015); }
.ls-number { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; font-weight: 500; }
.customer-name { font-weight: 600; }
.customer-loc { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.country-flag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; background: var(--bg-subtle); border-radius: 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; }
.amount { font-family: 'JetBrains Mono', ui-monospace, monospace; font-weight: 500; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; }
.status-pending { background: #fff4e0; color: #8b5a00; }
.status-pending::before { content: ''; width: 6px; height: 6px; background: #c47f17; border-radius: 50%; }
.status-done { background: #e7f4ec; color: #1f5234; }
.status-done::before { content: '✓'; font-size: 10px; }
.item-meta { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* BUTTONS */
.btn {
  padding: 7px 14px; border-radius: 6px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: white; cursor: pointer;
  transition: all 0.15s; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
  color: inherit;
}
.btn:hover { background: var(--bg-subtle); border-color: var(--border-strong); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-ghost { background: transparent; border-color: transparent; padding: 6px 8px; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger:hover { background: #fdecef; }
.btn-danger-solid { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger-solid:hover { background: #8a0019; border-color: #8a0019; }
.btn-icon { padding: 6px 8px; }
.btn-icon svg { width: 14px; height: 14px; margin: 0; }

.batch-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; margin-bottom: 12px;
  background: var(--text); color: white;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
}
.batch-bar .btn { background: rgba(255,255,255,0.12); color: white; border-color: rgba(255,255,255,0.18); }
.batch-bar .btn:hover { background: rgba(255,255,255,0.2); }
.batch-bar .btn-danger-solid { background: var(--danger); border-color: var(--danger); }
.batch-bar .btn-ghost { color: rgba(255,255,255,0.7); }
.batch-bar .btn-ghost:hover { background: rgba(255,255,255,0.08); color: white; }

input[type="checkbox"] { cursor: pointer; width: 14px; height: 14px; accent-color: var(--accent); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 13px; height: 13px; }

/* MODAL */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20,20,20,0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 24px;
}
.modal { background: white; border-radius: 12px; width: 100%; max-width: 720px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal-header { padding: 24px 28px 16px; border-bottom: 1px solid var(--border); }
.modal-title { font-family: 'Inter', system-ui, sans-serif; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
.modal-sub { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.modal-body { padding: 24px 28px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 28px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--bg-subtle); }
.section-title {
  font-size: 11px; color: var(--text-muted);
  letter-spacing: 0.06em; text-transform: uppercase;
  font-weight: 600; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; font-family: inherit; background: white; outline: none;
  transition: border-color 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--text); }
.field .value { font-size: 13px; padding: 8px 0; color: var(--text); }
.field .value strong { font-weight: 600; }

.item-row {
  display: grid; grid-template-columns: 1fr 100px 130px;
  gap: 12px; padding: 12px;
  background: var(--bg-subtle); border-radius: 8px;
  margin-bottom: 8px; align-items: center;
}

.alert { padding: 10px 14px; border-radius: 8px; font-size: 12px; display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; }
.alert-info { background: #f0f4f9; color: #2c4561; border: 1px solid #d6e0ee; }
.alert-warn { background: #fff8e0; color: #6b4f00; border: 1px solid #ecdca0; }
.alert-error { background: #fdecef; color: #75112a; border: 1px solid #f3c3cd; }
.alert svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: 10px;
  padding: 18px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 13px;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: white; color: var(--text); }
.dropzone strong { color: var(--text); display: block; margin-bottom: 4px; }
.dropzone .selected {
  display: inline-flex; align-items: center; gap: 8px;
  background: white; padding: 6px 10px; border-radius: 6px;
  border: 1px solid var(--border); margin-top: 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px;
  color: var(--text);
}
.dropzone .selected .remove { color: var(--danger); cursor: pointer; font-weight: bold; }
.dropzone input[type="file"] { display: none; }

.customs-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.customs-field { background: var(--bg-subtle); padding: 10px 12px; border-radius: 6px; border-left: 3px solid var(--accent); }
.customs-field.missing { border-left-color: var(--warning); background: #fff8e0; }
.customs-field .label { font-size: 10px; color: var(--text-muted); letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; margin-bottom: 3px; }
.customs-field .val { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; font-weight: 500; }

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.empty { padding: 60px 20px; text-align: center; color: var(--text-muted); }

/* LOGIN */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #fafaf7 0%, #f4f3ee 100%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: white; padding: 36px 32px;
  border-radius: 12px; box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.login-card h1 {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 26px; font-weight: 700; letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.login-card h1 span { color: var(--accent); }
.login-card .sub { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }

/* FORMS / ARTICLES */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.flash-ok { background: #e7f4ec; color: #1f5234; border: 1px solid #c0e0cd; }
.flash-err { background: #fdecef; color: #75112a; border: 1px solid #f3c3cd; }

.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--text); color: white;
  padding: 10px 16px; border-radius: 8px;
  font-size: 13px; box-shadow: var(--shadow-lg);
  z-index: 200; max-width: 400px;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 24px 20px; }
  .sidebar { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr; }
}
