/* ================= Admin panel ================= */
:root {
  --primary: #2563eb;
  --bg: #f4f6fa;
  --surface: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e6e9f0;
  --side: #0b1220;
  --radius: 14px;
  --primary-soft: color-mix(in srgb, var(--primary) 10%, white);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Plus Jakarta Sans", system-ui, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55; }
a { color: inherit; text-decoration: none; }
h1, h2 { margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.ic { flex-shrink: 0; }
img { max-width: 100%; }

.admin { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: 260px; background: var(--side); color: rgba(255,255,255,.72); display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40; transition: transform .25s; }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px; color: #fff; font-weight: 800; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-brand small { display: block; font-weight: 500; font-size: .76rem; color: rgba(255,255,255,.5); }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--primary); color: #fff; font-weight: 800; font-size: .88rem; flex-shrink: 0; }
.sidebar nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-weight: 600; font-size: .93rem; margin-bottom: 2px; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar nav a span { flex: 1; }
.sidebar nav em { font-style: normal; background: #ef4444; color: #fff; font-size: .72rem; font-weight: 800; padding: 1px 7px; border-radius: 999px; }
.side-sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 8px; }
.side-foot { padding: 14px 12px; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; font-size: .9rem; }
.side-foot a:hover { background: rgba(255,255,255,.06); color: #fff; }

.main { flex: 1; margin-left: 260px; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 18px 32px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 1.35rem; font-weight: 800; }
.menu-btn { display: none; background: none; border: 0; cursor: pointer; padding: 4px; color: var(--text); }
.content { padding: 28px 32px 60px; max-width: 1280px; }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 22px; box-shadow: 0 1px 2px rgba(15,23,42,.03); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { font-size: 1.05rem; }
.panel-head a { color: var(--primary); font-weight: 600; font-size: .9rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.two-col .panel { margin-bottom: 0; }
.two-col + .panel { margin-top: 22px; }
.welcome { margin: 0 0 18px; color: var(--muted); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat { display: flex; align-items: center; gap: 14px; margin: 0; transition: transform .15s, box-shadow .15s; }
.stat:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15,23,42,.08); }
.stat small { display: block; color: var(--muted); font-weight: 600; font-size: .82rem; }
.stat b { font-size: 1.6rem; font-weight: 800; }
.stat-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex-shrink: 0; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td small { display: block; color: var(--muted); font-size: .8rem; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--bg); }
.td-thumb { width: 64px; }
.td-actions { text-align: right; white-space: nowrap; }
.td-actions form, .table td form { display: inline; }
.mini-thumb { width: 48px; height: 48px; border-radius: 10px; overflow: hidden; display: grid; place-items: center; }
.mini-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-ph { background: linear-gradient(135deg, hsl(var(--h) 70% 55%), hsl(calc(var(--h) + 40) 75% 45%)); }
.thumb-ph span { color: #fff; font-weight: 800; font-size: .85rem; }
.empty-sm { padding: 20px 0; text-align: center; margin: 0; }
.link { color: var(--primary); font-weight: 600; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 700; background: #eef2f7; color: #475569; }
.badge-new { background: #fef3c7; color: #92400e; }
.badge-confirmed, .badge-contacted { background: #dbeafe; color: #1e40af; }
.badge-processing, .badge-in_progress { background: #ede9fe; color: #5b21b6; }
.badge-delivered, .badge-completed { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-btn { border: 0; cursor: pointer; padding: 4px 12px; border-radius: 999px; font: inherit; font-size: .78rem; font-weight: 700; }
.badge-btn.on { background: #dcfce7; color: #166534; }
.badge-btn.off { background: #f1f5f9; color: #64748b; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: #cbd5e1; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--primary); }
.btn-danger { color: #dc2626; }
.btn-danger:hover { background: #fef2f2; border-color: #fecaca; }
.btn-wa { background: #25d366; border-color: #25d366; color: #fff; }
.btn-sm { padding: 6px 11px; font-size: .84rem; }
.btn-block { width: 100%; }
.page-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-actions p { margin: 0; }
.back { display: inline-block; color: var(--muted); font-weight: 600; margin-bottom: 14px; font-size: .9rem; }
.back:hover { color: var(--primary); }
.quick { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.mini-counts { display: flex; gap: 22px; margin-top: 18px; color: var(--muted); font-size: .9rem; flex-wrap: wrap; }
.mini-counts b { color: var(--text); }
.mt { margin-top: 18px; }

/* Tabs */
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); padding: 5px; border-radius: 12px; margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: .9rem; color: var(--muted); white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { background: var(--primary); color: #fff; }
.tabs-sm { margin-bottom: 0; }
.filter-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; }
.filter-bar input { max-width: 300px; margin: 0 !important; }

/* Forms */
.form label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 14px; }
.form input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]), .form textarea, .form select, .filter-bar input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid #d8dde7; border-radius: 10px;
  font: inherit; font-weight: 500; background: #fff; color: var(--text);
}
.form textarea { resize: vertical; }
.form .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .86rem; }
.form input:focus, .form textarea:focus, .form select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }
.form small.muted, .field small.muted { display: block; margin-top: -8px; margin-bottom: 14px; font-size: .8rem; }
.hint { margin-top: -8px !important; }
.form-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 28px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); margin-top: 6px; }
.field { max-width: 720px; }
.narrow-form { max-width: 520px; }
.form hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0 18px; }

.switch { display: flex !important; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input[type=checkbox] { position: absolute; opacity: 0; width: 0; }
.switch span { width: 42px; height: 24px; border-radius: 999px; background: #cbd5e1; position: relative; transition: background .2s; flex-shrink: 0; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.img-field { margin-bottom: 16px; }
.img-field > label { margin-bottom: 8px !important; }
.img-row { display: flex; gap: 14px; align-items: center; }
.img-row img, .img-empty { width: 84px; height: 84px; border-radius: 12px; object-fit: cover; border: 1px solid var(--line); background: var(--bg); flex-shrink: 0; }
.img-empty { display: grid; place-items: center; color: var(--muted); }
.img-row small { display: block; margin-top: 6px; font-size: .8rem; }
.check-inline { display: flex !important; align-items: center; gap: 6px; font-weight: 500 !important; margin: 8px 0 0 !important; font-size: .85rem !important; color: #dc2626; }

.color-row { display: flex; gap: 10px; align-items: center; margin: 6px 0 14px; }
.color-row input[type=color] { width: 52px; height: 42px; border: 1px solid #d8dde7; border-radius: 10px; padding: 3px; background: #fff; cursor: pointer; }
.color-text { max-width: 130px; margin: 0 !important; font-family: ui-monospace, Consolas, monospace; }

.icon-pick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 6px 0 16px; }
.icon-pick label { margin: 0 !important; cursor: pointer; }
.icon-pick input { position: absolute; opacity: 0; }
.icon-pick span { display: grid; place-items: center; height: 44px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); transition: all .15s; }
.icon-pick input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* Details */
.details { display: grid; grid-template-columns: 130px 1fr; gap: 10px 16px; margin: 0 0 18px; }
.details dt { color: var(--muted); font-weight: 600; font-size: .86rem; }
.details dd { margin: 0; }
.details .big { font-size: 1.3rem; color: var(--primary); }
.totals { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 12px; display: grid; gap: 6px; max-width: 280px; margin-left: auto; }
.totals div { display: flex; justify-content: space-between; }
.totals span { color: var(--muted); }
.totals .grand { font-size: 1.12rem; border-top: 1px dashed var(--line); padding-top: 8px; }
.totals .grand span { color: var(--text); font-weight: 700; }

/* Messages */
.msg { padding: 0; margin-bottom: 10px; overflow: hidden; }
.msg-head { display: flex; align-items: center; gap: 14px; padding: 14px 18px; }
.msg-head div { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.unread .msg-head b::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-right: 8px; vertical-align: middle; }
.msg.open { border-color: color-mix(in srgb, var(--primary) 35%, white); }
.msg-body { padding: 0 18px 18px 68px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: .8rem; flex-shrink: 0; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; font-size: .92rem; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Auth (login + installer) */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(600px 400px at 80% 0%, color-mix(in srgb, var(--primary) 25%, transparent), transparent), var(--side); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 20px; padding: 36px 32px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.auth-card h1 { font-size: 1.5rem; margin-bottom: 4px; }
.auth-card > .muted { margin-top: 0; margin-bottom: 22px; }
.auth-logo { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: 18px; }
.auth-card .btn-block { margin-top: 6px; padding: 12px; }
.auth-card .back { display: block; text-align: center; margin: 18px 0 0; }
.auth-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.auth-card label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 14px; }
.auth-card input { display: block; width: 100%; margin-top: 6px; padding: 11px 12px; border: 1px solid #d8dde7; border-radius: 10px; font: inherit; }
.auth-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }

/* Shop additions */
.panel-title { font-size: 1rem; margin-bottom: 16px; }
.form-grid > div > .panel { margin-bottom: 18px; }
.form-grid .btn-block { margin-bottom: 18px; }
.gallery-edit { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin: 4px 0 12px; }
.g-item { margin: 0 !important; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
.g-item img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; }
.g-item span { display: flex; align-items: center; gap: 6px; padding: 6px 8px; font-size: .78rem; font-weight: 600; color: #dc2626; }
.form input[type=file] { display: block; margin: 6px 0 10px; font: inherit; font-size: .88rem; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 10px; padding: 14px 18px; margin-top: 4px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 -6px 20px rgba(15,23,42,.06); }
.stock-tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.stock-tag.in { background: #eef2f7; color: #334155; }
.stock-tag.low { background: #ffedd5; color: #c2410c; }
.stock-tag.out { background: #fee2e2; color: #b91c1c; }
.table td .badge { margin-top: 4px; }
.code-tag { display: inline-block; font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: .86rem; letter-spacing: .04em; padding: 3px 9px; border-radius: 7px; background: var(--primary-soft); color: var(--primary); border: 1px dashed color-mix(in srgb, var(--primary) 40%, white); }
.filter-bar select { width: auto; padding: 9px 12px; border: 1px solid #d8dde7; border-radius: 10px; font: inherit; background: #fff; }
.filter-bar { justify-content: flex-start; }

/* Responsive */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col, .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: 20px 0 60px rgba(0,0,0,.3); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-btn { display: block; }
  .topbar { padding: 14px 16px; }
  .content { padding: 20px 16px 50px; }
  .panel { padding: 16px; overflow-x: auto; }
  .table { min-width: 560px; }
  .form .table { min-width: 0; }
  .details { grid-template-columns: 1fr; gap: 2px; }
  .details dd { margin-bottom: 10px; }
  .msg-body { padding-left: 18px; }
}
@media (max-width: 520px) {
  .stat-grid, .form-row { grid-template-columns: 1fr; }
  .form-row { gap: 0; }
  .icon-pick { grid-template-columns: repeat(5, 1fr); }
}
