:root {
  --ink: #171512;
  --muted: #6f6a62;
  --line: #e8e2d9;
  --paper: #fff;
  --soft: #f7f4ef;
  --accent: #c96d2d;
  --accent-dark: #9f4d17;
  --danger: #b33131;
  --success: #2d7a4f;
  --shadow: 0 18px 50px rgba(30, 25, 18, .10);
  --radius: 18px;
}
* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--soft); }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); padding: 12px 13px; outline: none; transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(201, 109, 45, .12); }
textarea { resize: vertical; }
label { display: grid; gap: 7px; font-weight: 700; font-size: .91rem; }
label small { font-weight: 500; color: var(--muted); }

.auth-page { display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top left, rgba(201,109,45,.16), transparent 34%), #f4f0ea; }
.auth-card { width: min(460px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 24px; padding: 34px; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.auth-brand span, .admin-logo > span { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--ink); color: #fff; font-weight: 900; }
.auth-brand strong { letter-spacing: .08em; }
.auth-kicker, .admin-kicker { margin: 0 0 6px; color: var(--accent); text-transform: uppercase; letter-spacing: .12em; font-weight: 800; font-size: .72rem; }
.auth-card h1 { margin: 0; font-size: clamp(1.7rem, 4vw, 2.25rem); }
.auth-card > p:not(.auth-kicker):not(.auth-note) { color: var(--muted); line-height: 1.6; }
.auth-form { display: grid; gap: 16px; margin-top: 24px; }
.auth-note { color: var(--muted); font-size: .82rem; line-height: 1.5; margin: 18px 0 0; }
.auth-store-link { display: inline-block; margin-top: 22px; color: var(--ink); text-decoration: none; font-weight: 700; }

.admin-button { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 800; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .18s, box-shadow .18s, background .18s; }
.admin-button:hover { transform: translateY(-1px); }
.admin-button--primary { background: var(--accent); color: #fff; box-shadow: 0 10px 24px rgba(201,109,45,.22); }
.admin-button--primary:hover { background: var(--accent-dark); }
.admin-button--light { background: var(--soft); color: var(--ink); border: 1px solid var(--line); }
.admin-button--danger { background: var(--danger); color: #fff; }

.alert { border-radius: 13px; padding: 13px 15px; margin-bottom: 18px; font-weight: 700; }
.alert--error { background: #fff0f0; color: #8e2929; border: 1px solid #f1c7c7; }
.alert--success { background: #edf8f1; color: #236440; border: 1px solid #c7e7d2; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.admin-sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; background: #171512; color: #fff; display: flex; flex-direction: column; z-index: 40; }
.admin-logo { color: #fff; text-decoration: none; display: grid; grid-template-columns: 42px 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 11px; margin: 0 8px 34px; }
.admin-logo > span { grid-row: 1 / 3; background: #fff; color: #171512; }
.admin-logo strong { letter-spacing: .08em; font-size: .95rem; }
.admin-logo small { color: #aaa39a; font-size: .72rem; }
.admin-nav { display: grid; gap: 8px; }
.admin-nav button { border: 0; width: 100%; border-radius: 12px; padding: 12px 13px; background: transparent; color: #c9c3ba; text-align: left; font-weight: 750; display: flex; align-items: center; gap: 11px; }
.admin-nav button span { width: 22px; text-align: center; }
.admin-nav button:hover, .admin-nav button.is-active { background: rgba(255,255,255,.10); color: #fff; }
.admin-sidebar__footer { margin-top: auto; display: grid; gap: 12px; padding: 18px 10px 4px; border-top: 1px solid rgba(255,255,255,.12); }
.admin-sidebar__footer a { color: #c9c3ba; text-decoration: none; font-size: .88rem; font-weight: 700; }
.admin-sidebar__footer a:hover { color: #fff; }

.admin-main { min-width: 0; }
.admin-topbar { height: 78px; padding: 0 32px; background: rgba(255,255,255,.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 30; }
.admin-topbar > div { flex: 1; }
.admin-topbar p { margin: 0; color: var(--muted); font-size: .78rem; }
.admin-topbar strong { font-size: 1rem; }
.admin-menu { display: none; border: 0; background: var(--soft); border-radius: 10px; width: 42px; height: 42px; }
.admin-content { padding: 30px; max-width: 1500px; margin: 0 auto; }
.admin-view { display: none; }
.admin-view.is-active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.admin-heading { margin-bottom: 24px; }
.admin-heading--split { display: flex; justify-content: space-between; gap: 18px; align-items: end; }
.admin-heading h1 { margin: 0; font-size: clamp(1.8rem, 3vw, 2.55rem); }
.admin-heading p:last-child { color: var(--muted); margin-bottom: 0; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stats-grid article { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 8px 25px rgba(30,25,18,.04); }
.stats-grid span { display: block; color: var(--muted); font-weight: 700; font-size: .85rem; }
.stats-grid strong { display: block; font-size: 2.25rem; margin: 8px 0 4px; }
.stats-grid small { color: var(--muted); }

.admin-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(30,25,18,.045); overflow: hidden; }
.panel-heading { padding: 20px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.panel-heading h2, .form-section h2 { margin: 0 0 4px; font-size: 1.08rem; }
.panel-heading p { margin: 0; color: var(--muted); font-size: .88rem; }
.recent-admin-list { display: grid; }
.recent-row { display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 14px; padding: 14px 22px; border-bottom: 1px solid var(--line); }
.recent-row:last-child { border-bottom: 0; }
.recent-row img { width: 58px; height: 58px; object-fit: cover; border-radius: 12px; background: var(--soft); }
.recent-row h3 { margin: 0 0 3px; font-size: .96rem; }
.recent-row p { margin: 0; color: var(--muted); font-size: .82rem; }

.product-toolbar { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; }
.admin-search { flex: 1; position: relative; font-weight: 400; }
.admin-search span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.admin-search input { padding-left: 38px; }
.product-toolbar select { width: 210px; }
.admin-products { display: grid; }
.admin-product-row { display: grid; grid-template-columns: 74px minmax(190px, 1.3fr) minmax(100px, .6fr) minmax(110px, .6fr) minmax(110px, .7fr) auto; gap: 16px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.admin-product-row:last-child { border-bottom: 0; }
.admin-product-row img { width: 74px; height: 70px; object-fit: cover; border-radius: 12px; background: var(--soft); }
.admin-product-row h3 { margin: 0 0 5px; font-size: .98rem; }
.admin-product-row p { margin: 0; color: var(--muted); font-size: .8rem; }
.admin-product-row strong { font-size: .93rem; }
.status-pill { display: inline-flex; border-radius: 999px; padding: 6px 10px; font-size: .76rem; font-weight: 800; }
.status-pill--active { background: #eaf7ef; color: #24633f; }
.status-pill--inactive { background: #f3f0eb; color: #766f65; }
.row-actions { display: flex; gap: 7px; justify-content: end; }
.icon-button { width: 39px; height: 39px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.icon-button:hover { background: var(--soft); }
.icon-button--danger { color: var(--danger); }
.empty-admin { padding: 50px 20px; text-align: center; color: var(--muted); }

.settings-form { padding: 0; }
.form-section { padding: 24px; border-bottom: 1px solid var(--line); }
.admin-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; margin-top: 18px; }
.admin-form-grid--one { grid-template-columns: 1fr; }
.check-field { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 10px; }
.check-field input, .flags-grid input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-actions { padding: 20px 24px; display: flex; justify-content: end; }

.admin-modal { position: fixed; inset: 0; z-index: 100; display: none; }
.admin-modal.is-open { display: block; }
.admin-modal__backdrop { position: absolute; inset: 0; background: rgba(20,17,14,.62); backdrop-filter: blur(4px); }
.admin-modal__dialog { position: absolute; right: 0; top: 0; height: 100%; width: min(860px, 100%); background: #fff; overflow: auto; box-shadow: -20px 0 60px rgba(0,0,0,.16); }
.editor-header { position: sticky; top: 0; z-index: 4; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; }
.editor-header h2 { margin: 0; }
.editor-header > button { border: 0; background: var(--soft); width: 42px; height: 42px; border-radius: 12px; font-size: 1.5rem; }
.editor-section { padding: 24px; border-bottom: 1px solid var(--line); }
.editor-section h3 { margin: 0; }
.editor-section__heading { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.editor-section__heading p, .section-help { color: var(--muted); margin: 5px 0 0; font-size: .87rem; line-height: 1.5; }
.flags-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.flags-grid label { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 8px; background: var(--soft); padding: 10px 12px; border-radius: 10px; font-size: .85rem; }
.colors-editor { display: grid; gap: 16px; margin-top: 18px; }
.color-card { border: 1px solid var(--line); border-radius: 15px; padding: 16px; background: #fcfbf9; }
.color-card__top { display: grid; grid-template-columns: minmax(0, 1fr) 110px auto; gap: 10px; align-items: end; }
.color-card__top .remove-color { border: 1px solid #efc8c8; color: var(--danger); background: #fff3f3; border-radius: 10px; min-height: 43px; padding: 0 13px; }
.existing-images { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.image-chip { position: relative; width: 92px; height: 82px; border-radius: 11px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.image-chip img { width: 100%; height: 100%; object-fit: cover; }
.image-chip button { position: absolute; right: 4px; top: 4px; width: 25px; height: 25px; border-radius: 999px; border: 0; background: rgba(20,17,14,.82); color: #fff; }
.upload-help { color: var(--muted); font-size: .78rem; margin: 6px 0 0; }
.sizes-editor { display: grid; grid-template-columns: repeat(9, minmax(58px, 1fr)); gap: 9px; margin-top: 15px; }
.size-toggle { position: relative; }
.size-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.size-toggle span { display: grid; place-items: center; min-height: 48px; border: 1px solid var(--line); border-radius: 11px; background: #fff; font-weight: 800; }
.size-toggle input:checked + span { background: var(--ink); color: #fff; border-color: var(--ink); }
.existing-media { margin-top: 12px; color: var(--muted); font-size: .84rem; }
.editor-footer { position: sticky; bottom: 0; z-index: 4; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); padding: 16px 24px; border-top: 1px solid var(--line); display: flex; justify-content: end; gap: 10px; }

.confirm-dialog { position: fixed; inset: 0; z-index: 120; display: none; place-items: center; padding: 20px; background: rgba(20,17,14,.62); }
.confirm-dialog.is-open { display: grid; }
.confirm-dialog__box { width: min(430px, 100%); background: #fff; border-radius: 20px; padding: 24px; box-shadow: var(--shadow); }
.confirm-dialog__box h2 { margin-top: 0; }
.confirm-dialog__box p { color: var(--muted); line-height: 1.55; }
.confirm-dialog__box > div { display: flex; justify-content: end; gap: 10px; margin-top: 20px; }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-product-row { grid-template-columns: 70px minmax(180px, 1fr) 100px 105px auto; }
  .admin-product-row > :nth-child(4) { display: none; }
  .sizes-editor { grid-template-columns: repeat(5, minmax(58px, 1fr)); }
}
@media (max-width: 780px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { position: fixed; left: 0; top: 0; width: 260px; transform: translateX(-105%); transition: transform .22s; box-shadow: 18px 0 50px rgba(0,0,0,.25); }
  .admin-sidebar.is-open { transform: translateX(0); }
  .admin-menu { display: grid; place-items: center; }
  .admin-topbar { padding: 0 16px; }
  .admin-content { padding: 20px 14px; }
  .admin-heading--split { display: grid; align-items: start; }
  .admin-heading--split .admin-button { justify-self: start; }
  .admin-product-row { grid-template-columns: 62px 1fr auto; gap: 12px; }
  .admin-product-row img { width: 62px; height: 62px; }
  .admin-product-row > :nth-child(3), .admin-product-row > :nth-child(4), .admin-product-row > :nth-child(5) { display: none; }
  .product-toolbar { display: grid; }
  .product-toolbar select { width: 100%; }
  .admin-form-grid { grid-template-columns: 1fr; }
  .color-card__top { grid-template-columns: 1fr 90px; }
  .color-card__top .remove-color { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .auth-card { padding: 25px 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stats-grid article { padding: 16px; }
  .stats-grid strong { font-size: 1.8rem; }
  .admin-topbar > .admin-button { display: none; }
  .panel-heading { align-items: start; }
  .recent-row { grid-template-columns: 52px 1fr; }
  .recent-row > button { grid-column: 2; justify-self: start; }
  .editor-section, .editor-header { padding-left: 16px; padding-right: 16px; }
  .sizes-editor { grid-template-columns: repeat(3, 1fr); }
  .editor-footer { padding: 12px 16px; }
}
