*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

:root {
  color-scheme: light;
  --ink: #111;
  --bg: #ececea;
  --bg2: #fff;
  --bg3: #f4f4f2;
  --white: #fff;
  --white2: #4f4f53;
  --muted: #66666a;
  --green: #d7a5ff;
  --green-text: #61287d;
  --green2: #c88ef3;
  --border: #d8d8d3;
  --borderg: #b57bdc;
  --red: #a12a2a;
  --yellow: #7b5900;
  --sidebar: 258px;
  --serif: "Rajdhani", system-ui, sans-serif;
  --sans: "Inter", system-ui, sans-serif;
  --mono: "Space Mono", monospace;
}

html { min-width: 320px; overflow-x: hidden; background: var(--bg); scroll-behavior: smooth; }
body { min-height: 100vh; display: flex; overflow-x: hidden; background: var(--bg); color: var(--ink); font-family: var(--sans); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.sidebar {
  position: fixed;
  z-index: 60;
  left: 14px;
  top: 14px;
  width: var(--sidebar);
  height: calc(100vh - 28px);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .06);
  transition: transform .2s ease;
}

.sidebar-logo { min-height: 76px; display: flex; align-items: center; gap: 11px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.sidebar-logo img { width: 38px; height: 38px; flex: 0 0 38px; object-fit: contain; border-radius: 50%; background: #111; padding: 4px; filter: invert(1); }
.sidebar-logo .logo-sym { display: none; }
.sidebar-logo .logo-name { color: #111; font: 700 20px var(--serif); }
.sidebar-user { padding: 15px 18px; border-bottom: 1px solid var(--border); }
.sidebar-user-name { overflow: hidden; color: #111; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { margin-top: 4px; color: var(--green-text); font: 700 9px var(--mono); text-transform: uppercase; }
.sidebar-nav { flex: 1; padding: 10px; }
.nav-sec { padding: 14px 10px 7px; color: #86868a; font: 700 8px var(--mono); text-transform: uppercase; }
.nav-item { min-height: 42px; display: flex; align-items: center; gap: 10px; margin: 2px 0; padding: 0 11px; border-radius: 6px; color: #4f4f53; font-size: 11px; font-weight: 600; text-decoration: none; cursor: pointer; user-select: none; }
.nav-item:hover { background: #f0f0ed; color: #111; }
.nav-item.active { background: var(--green); color: #111; }
.nav-icon { width: 18px; display: grid; place-items: center; flex: 0 0 18px; }
.nav-badge { margin-left: auto; padding: 2px 6px; border-radius: 5px; background: #111; color: #fff; font: 700 8px var(--mono); }
.sidebar-bottom { padding: 12px; border-top: 1px solid var(--border); }

.main { width: calc(100% - 286px); min-width: 0; min-height: 100vh; display: flex; flex-direction: column; margin-left: 286px; }
.topbar { position: sticky; z-index: 45; top: 14px; min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 14px 14px 0 0; padding: 12px 20px; border: 1px solid var(--border); border-radius: 8px; background: rgba(255, 255, 255, .94); box-shadow: 0 8px 24px rgba(0, 0, 0, .045); backdrop-filter: blur(12px); }
.topbar > div:first-child { min-width: 0; }
.topbar-title { overflow: hidden; color: #111; font: 600 24px var(--serif); text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.topbar-sub { overflow: hidden; margin-top: 2px; color: #77777b; font: 700 8px var(--mono); text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.content { flex: 1; min-width: 0; margin: 14px 14px 14px 0; padding: 24px; border: 1px solid rgba(255,255,255,.9); border-radius: 8px; background: #f5f5f3; }

.panel { overflow: hidden; margin-bottom: 16px; border: 1px solid var(--border); border-radius: 8px; background: #fff; box-shadow: 0 7px 20px rgba(0, 0, 0, .035); }
.panel-header { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel-title { color: #111; font: 700 11px var(--serif); text-transform: uppercase; }
.panel-title::before { content: ""; width: 8px; height: 8px; display: inline-block; margin-right: 8px; border-radius: 3px; background: var(--green); }
.panel-body { padding: 18px; }

.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { min-height: 120px; display: flex; flex-direction: column; justify-content: space-between; padding: 18px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.stat-card:nth-child(2) { background: #f1e3fc; }
.stat-label { color: #66666a; font: 700 9px var(--mono); text-transform: uppercase; }
.stat-value { min-height: 34px; color: #111; font: 600 32px/1 var(--serif); white-space: nowrap; }
.stat-value em { color: var(--green-text); font-size: 12px; font-style: normal; }
.dashboard-panels { display: grid; grid-template-columns: 1.35fr .65fr; gap: 14px; }
#dash-orders { min-height: 260px; }

.tbl-wrap { width: 100%; min-height: 60px; overflow-x: auto; }
.data-table { width: 100%; min-width: 720px; border-collapse: collapse; }
.data-table th { padding: 12px 14px; border-bottom: 1px solid var(--border); color: #6b6b6f; font: 700 9px var(--mono); text-align: left; text-transform: uppercase; }
.data-table td { padding: 13px 14px; border-bottom: 1px solid #e5e5e1; color: #444448; font-size: 12px; line-height: 1.5; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: #f6f6f4; }
.td-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.btn, .btn-signout, .btn-view-site { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 14px; border: 1px solid #111; border-radius: 7px; background: #111; color: #fff; font: 700 9px var(--mono); text-decoration: none; text-transform: uppercase; cursor: pointer; }
.btn:hover, .btn-signout:hover, .btn-view-site:hover { background: var(--green); color: #111; }
.btn-outline { background: #fff; color: #111; }
.btn-green { background: var(--green); color: #111; }
.btn-red { border-color: var(--red); background: #fff; color: var(--red); }
.btn-red:hover { background: var(--red); color: #fff; }
.btn-sm { min-height: 30px; padding: 0 9px; font-size: 8px; }
.btn-signout { width: 100%; }
.hamburger { width: 42px; height: 40px; display: none; place-items: center; border: 1px solid #111; border-radius: 7px; background: #fff; color: #111; cursor: pointer; }

.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 5px; font: 700 8px var(--mono); text-transform: uppercase; }
.bg-green { background: #e8f6bd; color: #294100; }
.bg-yellow { background: #fff2c4; color: #674800; }
.bg-red { background: #ffdddd; color: #791d1d; }
.bg-muted { background: #ececea; color: #55555a; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-label { color: #5d5d61; font: 700 9px var(--mono); text-transform: uppercase; }
.req { color: var(--red); }
.form-input, .form-select, .form-textarea, .search-input { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid #cececa; border-radius: 7px; background: #f8f8f6; color: #111; outline: none; }
.form-textarea { min-height: 120px; padding-top: 12px; resize: vertical; }
.form-input:focus, .form-select:focus, .form-textarea:focus, .search-input:focus { border-color: #111; box-shadow: 0 0 0 3px rgba(215, 165, 255, .27); }
.form-input::placeholder, .form-textarea::placeholder, .search-input::placeholder { color: #8b8b8f; }
.form-hint { color: #77777b; font-size: 10px; line-height: 1.5; }
.hint-warn { color: var(--yellow); }
.checkbox-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; accent-color: #111; }
.checkbox-row span { color: #55555a; font-size: 11px; }
.search-input { width: min(240px, 100%); }

.rich-bar { display: flex; flex-wrap: wrap; gap: 5px; padding: 7px; border: 1px solid var(--border); border-radius: 7px 7px 0 0; background: #f0f0ed; }
.rich-btn { min-width: 32px; min-height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: #111; cursor: pointer; }
.rich-btn:hover { border-color: #111; background: #111; color: #fff; }
.rich-editor { min-height: 220px; padding: 16px; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 7px 7px; background: #fff; color: #111; line-height: 1.7; outline: none; }

.modal-overlay { position: fixed; z-index: 300; inset: 0; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(17, 17, 17, .54); backdrop-filter: blur(5px); }
.modal-overlay.open { display: flex; }
.modal { width: min(680px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; border: 1px solid #111; border-radius: 8px; background: #fff; box-shadow: 0 24px 70px rgba(0, 0, 0, .22); }
.modal-lg { width: min(860px, 100%); }
.modal-header { position: sticky; z-index: 2; top: 0; min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: #fff; }
.modal-title { color: #111; font: 600 24px var(--serif); text-transform: uppercase; }
.modal-close { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid #111; border-radius: 6px; background: #fff; color: #111; cursor: pointer; }
.modal-close:hover { background: #111; color: #fff; }
.modal-body { padding: 20px; }
.modal-footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); background: #fff; }

.toast { position: fixed; z-index: 999; right: 20px; bottom: 20px; max-width: 380px; padding: 13px 17px; border: 1px solid #111; border-radius: 7px; background: #111; color: #fff; font-size: 11px; opacity: 0; transform: translateY(20px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: none; }
.toast.err { border-color: var(--red); background: var(--red); }

.view { display: none; }
.view.active { display: block; animation: admin-view .18s ease; }
@keyframes admin-view { from { opacity: 0; transform: translateY(5px); } }
.guide-hero { margin-bottom: 16px; padding: 26px; border: 1px solid #111; border-radius: 8px; background: #111; color: #fff; }
.guide-hero h2 { margin-bottom: 8px; color: #fff; font: 600 32px var(--serif); text-transform: uppercase; }
.guide-hero p { color: #c5c5c8; font-size: 12px; line-height: 1.7; }
.guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.guide-card { padding: 20px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.guide-card h3 { margin-bottom: 10px; color: #111; font: 600 19px var(--serif); text-transform: uppercase; }
.guide-card h4 { margin: 16px 0 7px; color: #111; font: 700 10px var(--mono); text-transform: uppercase; }
.guide-card p, .guide-card li { color: #55555a; font-size: 11px; line-height: 1.7; }
.guide-card ul, .guide-card ol { padding-left: 18px; }
.guide-table { width: 100%; margin-top: 12px; border-collapse: collapse; }
.guide-table th, .guide-table td { padding: 10px; border: 1px solid var(--border); color: #4e4e52; font-size: 10px; line-height: 1.6; text-align: left; vertical-align: top; }
.guide-table th { background: #f0f0ed; color: #111; font-weight: 700; }
.guide-note { margin-top: 13px; padding: 13px; border-left: 4px solid var(--green); background: #f0f0ed; color: #4d4d51; font-size: 11px; line-height: 1.65; }
.guide-kbd { padding: 2px 6px; border-radius: 4px; background: var(--green); color: #111; font: 700 9px var(--mono); }

.admin-loading, .auth-screen { width: 100%; min-height: 100vh; align-items: center; justify-content: center; flex-direction: column; }
.admin-loading { display: flex; gap: 14px; }
.admin-loading p { color: #666; font: 700 9px var(--mono); text-transform: uppercase; }
.auth-screen { display: none; }
.auth-box { width: min(430px, calc(100% - 32px)); padding: 34px; border: 1px solid #111; border-radius: 8px; background: #fff; box-shadow: 0 18px 48px rgba(0, 0, 0, .1); text-align: center; }
.auth-box h2 { color: #111; font: 600 36px var(--serif); text-transform: uppercase; }
.auth-box > p { margin: 8px 0 24px; color: #666; font-size: 11px; }
.auth-err { display: none; margin-bottom: 16px; padding: 12px; border: 1px solid #d99c9c; border-radius: 7px; background: #fff0f0; color: #8f1d1d; font-size: 11px; line-height: 1.5; text-align: left; }
.spinner { width: 34px; height: 34px; margin: 14px auto; border: 2px solid #d4d4cf; border-top-color: #111; border-radius: 50%; animation: admin-spin .75s linear infinite; }
@keyframes admin-spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .sidebar { left: 0; top: 0; width: min(290px, 88vw); height: 100vh; border-radius: 0 8px 8px 0; transform: translateX(-105%); }
  .sidebar.open { transform: none; }
  .main { width: 100%; margin-left: 0; }
  .topbar { top: 8px; margin: 8px 8px 0; }
  .content { margin: 8px; padding: 16px; }
  .hamburger { display: grid; }
  .dashboard-panels { grid-template-columns: 1fr; }
  .guide-grid { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .topbar { min-height: 64px; padding: 10px 12px; }
  .topbar-title { font-size: 20px; }
  .topbar-sub { display: none; }
  .btn-view-site { min-height: 38px; padding: 0 9px; }
  .content { padding: 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { min-height: 98px; padding: 13px; }
  .stat-value { font-size: 27px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-full { grid-column: auto; }
  .panel-header, .panel-body { padding: 13px; }
  .panel-header > div { width: 100%; }
  .search-input { width: 100%; }
  .modal-overlay { align-items: flex-end; padding: 6px; }
  .modal { max-height: calc(100vh - 12px); }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; }
  .toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr; }
  .btn-view-site { display: none; }
}
