*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f4f0; --surface: #ffffff; --border: #e2e0d8;
  --text: #1a1a18; --muted: #7a7870; --accent: #1a1a18; --accent-fg: #ffffff;
  --info-bg: #e8f0fe; --info: #1a56db;
  --success-bg: #e3f9e5; --success: #1a7f37;
  --warn-bg: #fff8e1; --warn: #92600a;
  --danger-bg: #fde8e8; --danger: #c0392b;
  --radius: 10px; --radius-sm: 6px;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; min-height: 100vh; }

/* Shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
nav { background: var(--text); color: var(--accent-fg); display: flex; flex-direction: column; }
nav .brand { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
nav .brand h1 { font-size: 16px; font-weight: 600; letter-spacing: -.3px; }
nav .brand p  { font-size: 11px; opacity: .5; margin-top: 2px; }
nav .brand .store-badge { font-size: 10px; opacity: .6; margin-top: 4px;
  background: rgba(255,255,255,.1); padding: 2px 6px; border-radius: 4px; display: inline-block; }
nav ul { list-style: none; padding: 10px 0; flex: 1; }
nav ul li a { display: flex; align-items: center; gap: 10px; padding: 9px 18px;
  color: rgba(255,255,255,.65); text-decoration: none; font-size: 13px;
  transition: background .15s, color .15s; cursor: pointer; }
nav ul li a:hover, nav ul li a.active { background: rgba(255,255,255,.1); color: #fff; }
nav ul li a svg { width: 16px; height: 16px; flex-shrink: 0; }
nav .nav-section { padding: 4px 18px 2px; font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; opacity: .35; margin-top: 8px; }
nav .logout { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.1); }
nav .logout a { color: rgba(255,255,255,.5); font-size: 12px; text-decoration: none; }
nav .logout a:hover { color: rgba(255,255,255,.8); }
main { padding: 28px 32px; overflow-y: auto; }
h2 { font-size: 20px; font-weight: 600; margin-bottom: 4px; letter-spacing: -.3px; }
.subtitle { color: var(--muted); font-size: 13px; margin-bottom: 24px; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab-btn { padding: 10px 18px; font-size: 13px; font-weight: 500; cursor: pointer;
  border: none; background: none; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color .15s, border-color .15s; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; }
.card-title { font-size: 13px; font-weight: 600; margin-bottom: 14px;
  display: flex; align-items: center; gap: 7px; }
.card-title svg { width: 15px; height: 15px; color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: all .15s; text-decoration: none; }
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-primary:hover { opacity: .85; }
.btn-danger { color: var(--danger); border-color: #f5c2c2; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn svg { width: 14px; height: 14px; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600;
  color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.form-control { width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; background: var(--bg);
  color: var(--text); transition: border-color .15s; }
.form-control:focus { outline: none; border-color: var(--accent); background: var(--surface); }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* Drop zone */
.drop-zone { border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 28px 20px; text-align: center; cursor: pointer;
  transition: all .15s; background: var(--bg); }
.drop-zone:hover, .drop-zone.drag { border-color: var(--accent); background: var(--surface); }
.drop-zone svg { width: 28px; height: 28px; color: var(--muted); margin-bottom: 8px; }
.drop-zone p { color: var(--muted); font-size: 13px; }
.drop-zone strong { color: var(--text); }
.drop-zone.has-file { border-color: var(--success); background: var(--success-bg); }
.drop-zone .file-preview { display: flex; align-items: center; gap: 10px;
  justify-content: center; margin-top: 8px; }
.drop-zone .file-preview img { max-height: 60px; border-radius: 4px; }
input[type=file] { display: none; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 8px 12px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  border-bottom: 1px solid var(--border); background: var(--bg); }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }
.data-table .cb-col { width: 36px; }
.data-table .actions { display: flex; gap: 6px; }
.data-table .expand-row { cursor: pointer; }
.data-table .expand-row:hover td { background: #f0f0ec; }

/* Line items accordion */
.line-items-row { display: none; }
.line-items-row.open { display: table-row; }
.line-items-inner { padding: 0 12px 12px 36px; }
.line-item-row { display: flex; align-items: center; gap: 10px; padding: 6px 0;
  border-bottom: 1px solid var(--border); }
.line-item-row:last-child { border-bottom: none; }
.line-item-check { flex-shrink: 0; }
.line-item-info { flex: 1; font-size: 13px; }
.line-item-info .li-title { font-weight: 500; }
.line-item-info .li-meta  { font-size: 11px; color: var(--muted); }
.line-item-qty { font-size: 12px; color: var(--muted); min-width: 50px; text-align: right; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 99px; font-size: 11px; font-weight: 600;
  background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.badge-new      { background: var(--info-bg);    border-color: #b3c9f7; color: var(--info); }
.badge-queued   { background: var(--warn-bg);    border-color: #ffd787; color: var(--warn); }
.badge-printed  { background: var(--success-bg); border-color: #b7deba; color: var(--success); }
.badge-cancelled{ background: var(--danger-bg);  border-color: #f5c2c2; color: var(--danger); }
.badge-matched  { background: var(--success-bg); border-color: #b7deba; color: var(--success); }
.badge-unmatched{ background: var(--warn-bg);    border-color: #ffd787; color: var(--warn); }
.badge-green    { background: var(--success-bg); border-color: #b7deba; color: var(--success); }
.badge-red      { background: var(--danger-bg);  border-color: #f5c2c2; color: var(--danger); }

/* Alerts */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px;
  display: flex; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.alert-info    { background: var(--info-bg);    color: var(--info); }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-warn    { background: var(--warn-bg);    color: var(--warn); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger); }
.alert svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; }
.stat .val { font-size: 28px; font-weight: 600; letter-spacing: -1px; }
.stat .lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Spinner */
.spinner { width: 14px; height: 14px; border: 2px solid currentColor;
  border-top-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: none; align-items: center; justify-content: center; z-index: 1000; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.2); width: 90%; max-width: 860px;
  max-height: 90vh; display: flex; flex-direction: column; }
.modal-header { display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 22px; line-height: 1; padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px; }

/* Print preview canvas */
#preview-canvas-wrap { overflow-y: auto; max-height: 60vh; }
.preview-page { background: white; border: 1px solid var(--border);
  border-radius: 4px; margin-bottom: 12px; position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,.08); }

/* Design thumb grid */
.design-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px; margin-top: 12px; }
.design-thumb { border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; position: relative; background: var(--bg); }
.design-thumb img { width: 100%; aspect-ratio: 9/16; object-fit: contain; padding: 4px; display: block; }
.design-thumb .thumb-label { font-size: 10px; padding: 3px 6px; background: var(--surface);
  border-top: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Resolution warning */
.res-warn { font-size: 11px; color: var(--warn); margin-top: 4px; }
.res-ok   { font-size: 11px; color: var(--success); margin-top: 4px; }

/* Batch action bar */
.batch-bar { position: sticky; bottom: 0; background: var(--text); color: white;
  padding: 12px 20px; display: none; align-items: center; justify-content: space-between;
  border-radius: var(--radius) var(--radius) 0 0; margin: 0 -32px;
  box-shadow: 0 -4px 20px rgba(0,0,0,.15); z-index: 100; }
.batch-bar.visible { display: flex; }
.batch-bar .batch-info { font-size: 13px; }
.batch-bar .batch-info span { font-weight: 600; }
.batch-bar .batch-actions { display: flex; gap: 10px; }

/* Toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 10px; }

/* Section header */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

/* Variant card */
.variant-card { border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; margin-bottom: 12px; background: var(--bg); }
.variant-card-title { font-weight: 600; font-size: 13px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px; }
.variant-card .design-status { font-size: 11px; }

/* Product import card */
.product-card { display: flex; gap: 16px; padding: 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; }
.product-card img { width: 80px; height: 80px; object-fit: contain; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); }
.product-card-info h3 { font-size: 15px; font-weight: 600; }
.product-card-info p  { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state svg { width: 48px; height: 48px; opacity: .3; margin-bottom: 12px; }
.empty-state h3 { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* Login page */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: white; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 36px 32px; width: 100%; max-width: 380px; }
.login-box h1 { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.login-box p  { font-size: 13px; color: var(--muted); margin-bottom: 28px; }

@media (max-width: 768px) {
  .shell { grid-template-columns: 1fr; }
  nav { display: none; }
  .stats { grid-template-columns: repeat(2,1fr); }
}
