:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1b2430;
  --ink-soft: #5b6672;
  --line: #e2e6eb;
  --brand: #1f6f54;
  --brand-ink: #ffffff;
  --brand-soft: #e7f2ee;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --ok: #1f6f54;
  --ok-soft: #e7f2ee;
  --pending-soft: #fff6e6;
  --radius: 10px;
  --space: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 4px; }
code { background: #eef1f4; padding: 1px 5px; border-radius: 5px; font-size: 14px; word-break: break-all; }
.lead { color: var(--ink-soft); margin: 0 0 24px; max-width: 60ch; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:focus-visible { outline: 3px solid #9cbfe4; outline-offset: 2px; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover:not(:disabled) { background: #195c45; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: #c8cfd6; }
.btn-secondary:hover:not(:disabled) { background: #f0f2f5; }
.btn-quiet { background: transparent; color: var(--ink-soft); border-color: #d4d9df; min-height: 38px; }
.btn-quiet:hover { background: #eef1f4; }
.btn-block { width: 100%; }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { background: var(--surface); width: 100%; max-width: 380px; padding: 32px; border-radius: 14px; box-shadow: 0 1px 3px rgba(16,24,40,.08); }
.brand { font-weight: 800; letter-spacing: -.3px; color: var(--brand); }
.brand-lg { font-size: 26px; }
.auth-lead { color: var(--ink-soft); margin: 4px 0 20px; }
.auth-card label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 14px; }
.auth-card input { width: 100%; }

/* Layout shell */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: #10261f; color: #cfe3db; padding: 20px 14px; }
.sidebar .brand { color: #ffffff; font-size: 20px; padding: 6px 10px 18px; }
.sidebar nav a { display: block; color: #cfe3db; text-decoration: none; padding: 10px 12px; border-radius: 8px; font-size: 15px; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.nav-group { text-transform: uppercase; font-size: 11px; letter-spacing: .08em; color: #86a99c; padding: 18px 12px 6px; }

.main { display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-bottom: 1px solid var(--line); padding: 12px 28px; }
.store-name { font-weight: 700; }
.store-sub { color: var(--ink-soft); font-size: 13px; }
.content { padding: 28px 36px; width: 100%; max-width: 1360px; margin: 0 auto; }
/* Forms stay readable while tables and dashboards fill the width. */
form.card { max-width: 860px; }

/* Cards & forms */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.field { margin-bottom: 20px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.req { color: var(--ink-soft); font-weight: 400; font-size: 13px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid #c8cfd6;
  border-radius: 8px;
  background: #fff;
  min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid #9cbfe4; outline-offset: 1px; border-color: var(--brand); }
.help { color: var(--ink-soft); font-size: 13px; margin: 6px 0 0; }
.field-error { color: var(--danger); font-size: 14px; margin: 6px 0 0; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }

/* Task list (dashboard) */
.task-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.task { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.task p { margin: 4px 0 0; color: var(--ink-soft); }
.task-state { font-size: 14px; }

/* Alerts & result panels */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.result { margin-top: 20px; padding: 16px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.result pre { margin: 10px 0 0; white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; background: #0f1b17; color: #d7e7e0; padding: 12px; border-radius: 8px; font-size: 13px; }
.result-ok { border-left: 4px solid var(--ok); }
.result-error { border-left: 4px solid var(--danger); }
.result-pending { border-left: 4px solid #d9a441; background: var(--pending-soft); }

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
  .sidebar .brand { padding: 6px 10px; }
  .nav-group { display: none; }
  .content { padding: 18px 16px; }
  .task { flex-direction: column; align-items: flex-start; }
}

/* Page heads and utility */
.page-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:20px; }
.page-head h1 { margin:0; }
.head-actions { display:flex; gap:8px; flex-wrap:wrap; }
.muted { color: var(--ink-soft); }
.mt { margin-top:24px; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); border:0; }
.btn-sm { min-height:34px; padding:0 12px; font-size:13px; }
.btn-danger { background:#fff; color:var(--danger); border-color:#e7b4af; }
.btn-danger:hover:not(:disabled) { background:var(--danger-soft); }

/* Stat tiles */
.stat-row { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:22px; }
.stat { background:var(--surface); border:1px solid var(--line); border-radius:12px; padding:16px 18px; }
.stat-label { color:var(--ink-soft); font-size:13px; }
.stat-value { font-size:26px; font-weight:700; margin-top:4px; }

/* Two-column */
.two-col { display:grid; grid-template-columns:1fr 1fr; gap:16px; align-items:start; }
.card-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; }
.card-head h2 { margin:0; }

/* Tables */
.table { width:100%; border-collapse:collapse; font-size:14px; }
.table th { text-align:left; color:var(--ink-soft); font-weight:600; font-size:12px; text-transform:uppercase; letter-spacing:.04em; padding:8px 10px; border-bottom:1px solid var(--line); }
.table td { padding:10px; border-bottom:1px solid var(--line); vertical-align:middle; }
.table tbody tr:last-child td { border-bottom:none; }
.table .num { text-align:right; }
.table tfoot td { border-top:2px solid var(--line); border-bottom:none; }
.card-table { background:var(--surface); border:1px solid var(--line); border-radius:12px; padding:6px 10px; }
.row-actions { display:flex; gap:6px; justify-content:flex-end; align-items:center; }
.row-actions form { display:inline; }

/* Badges */
.badge { display:inline-block; padding:2px 9px; border-radius:999px; font-size:12px; font-weight:600; background:#eef1f4; color:#43505e; }
.badge-paid, .badge-fulfilled { background:var(--ok-soft); color:var(--ok); }
.badge-pending { background:#fff3d6; color:#8a6400; }
.badge-refunded { background:#f1e9fb; color:#6b3fa0; }
.badge-warn { background:var(--danger-soft); color:var(--danger); }

/* Filter chips */
.filter-bar { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:16px; }
.chip { padding:6px 14px; border-radius:999px; border:1px solid #c8cfd6; color:var(--ink-soft); text-decoration:none; font-size:14px; background:var(--surface); text-transform:capitalize; }
.chip-on { background:var(--brand); color:#fff; border-color:var(--brand); }

/* Forms */
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.field-narrow { max-width:220px; }
.field-check { display:flex; align-items:center; gap:10px; margin-bottom:18px; }
.field-check input { width:auto; min-height:auto; }
.field-check label { margin:0; font-weight:500; }
.qty { max-width:90px; text-align:right; }
.status-form { display:flex; gap:10px; align-items:center; }
.status-form select { max-width:200px; }

/* Misc */
.plain-list { list-style:none; margin:0; padding:0; }
.plain-list li { display:flex; align-items:center; justify-content:space-between; padding:8px 0; border-bottom:1px solid var(--line); }
.plain-list li:last-child { border-bottom:none; }
.kv { display:flex; justify-content:space-between; gap:12px; margin:6px 0; border-bottom:1px dashed var(--line); padding-bottom:6px; }
.kv span { color:var(--ink-soft); }
.empty { text-align:center; padding:40px 20px; }
.empty p { color:var(--ink-soft); margin:0 0 14px; }

@media (max-width: 860px) {
  .stat-row { grid-template-columns:repeat(2,1fr); }
  .two-col, .grid-2 { grid-template-columns:1fr; }
}

/* Admin topbar extras */
.topbar-actions { display:flex; gap:8px; align-items:center; }
.auth-hint { color: var(--ink-soft); font-size: 14px; margin-top: 18px; text-align: center; }
.auth-hint a { color: var(--brand); text-decoration: none; }

/* ---- Storefront ---- */
.shop-body { background:#fbfbfa; display:flex; flex-direction:column; min-height:100vh; }
.shop-header { background:var(--surface); border-bottom:1px solid var(--line); position:sticky; top:0; z-index:5; }
.shop-header-inner { max-width:1100px; margin:0 auto; padding:14px 24px; display:flex; align-items:center; justify-content:space-between; }
.shop-brand { font-weight:800; font-size:20px; color:var(--brand); text-decoration:none; letter-spacing:-.3px; }
.shop-nav { display:flex; align-items:center; gap:20px; }
.shop-nav a, .shop-nav .linklike { color:var(--ink); text-decoration:none; font-size:15px; font-weight:500; background:none; border:none; cursor:pointer; font-family:inherit; padding:0; }
.shop-nav a:hover, .shop-nav .linklike:hover { color:var(--brand); }
.inline-form { display:inline; }
.cart-badge { background:var(--brand); color:#fff; border-radius:999px; padding:1px 8px; font-size:12px; font-weight:700; }
.shop-main { flex:1 0 auto; width:100%; max-width:1100px; margin:0 auto; padding:28px 24px 60px; display:flex; flex-direction:column; }
.shop-auth { flex:1 0 auto; display:grid; place-items:center; padding:24px 0; }
.shop-auth .narrow-card { margin:0; width:100%; }
.shop-footer { flex-shrink:0; width:100%; border-top:1px solid var(--line); margin-top:24px; }
.shop-footer-inner { max-width:1100px; margin:0 auto; padding:24px; color:var(--ink-soft); font-size:14px; }
.shop-footer a { color:var(--ink-soft); }

.shop-hero { padding:16px 0 28px; }
.shop-hero h1 { font-size:32px; margin:0 0 6px; }
.shop-hero p { color:var(--ink-soft); font-size:17px; margin:0; }

.product-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(230px,1fr)); gap:20px; }
.product-card { background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:16px; display:flex; flex-direction:column; }
.product-thumb, .product-detail-thumb { display:grid; place-items:center; background:linear-gradient(135deg,#e7f2ee,#d7e9e1); border-radius:10px; color:var(--brand); font-weight:800; text-decoration:none; overflow:hidden; }
.product-thumb img, .product-detail-thumb img { width:100%; height:100%; object-fit:cover; display:block; }
.product-thumb { height:150px; font-size:44px; margin-bottom:12px; }
.product-card h2 { font-size:16px; margin:0 0 4px; }
.product-card h2 a { color:var(--ink); text-decoration:none; }
.product-price { font-weight:700; margin:0 0 2px; }
.product-stock { color:var(--ink-soft); font-size:13px; margin:0 0 12px; }
.product-card form, .product-card > .btn-block { margin-top:auto; }

.back-link { display:inline-block; margin-bottom:16px; color:var(--ink-soft); text-decoration:none; }
.product-detail { display:grid; grid-template-columns:360px 1fr; gap:28px; align-items:start; }
.product-detail-thumb { height:300px; font-size:90px; }
.product-detail-info h1 { margin:0 0 6px; }
.product-price-lg { font-size:24px; font-weight:700; margin:0 0 4px; }
.product-desc { margin:14px 0; color:#3a4651; }
.add-form { display:flex; align-items:flex-end; gap:12px; margin-top:16px; }
.add-form label { display:block; font-size:13px; color:var(--ink-soft); margin-bottom:4px; }

.narrow-card { max-width:420px; margin:10px auto; }
.narrow-card h1 { margin-top:0; }
.center { text-align:center; }

@media (max-width:720px) {
  .product-detail { grid-template-columns:1fr; }
  .product-detail-thumb { height:220px; }
}

.btn-small { padding: 4px 10px; font-size: 0.85rem; margin-top: 6px; }
.logo-preview { margin-top: 10px; }
.logo-preview img { max-width: 240px; max-height: 120px; border: 1px solid #ddd; border-radius: 4px; }
.logo-preview pre { background: #0b1020; color: #e6e6e6; padding: 10px; border-radius: 4px; overflow: auto; max-height: 240px; }
