/* ============================================================
   FAULT ADMIN — premium light UI (klimat admor)
   papier / tusz / cynober / pigułki / sentence case
   ============================================================ */
:root {
    --a-bg: #f6f4f0;
    --a-panel: #ffffff;
    --a-panel2: #f0ede7;
    --a-line: #e4dfd6;
    --a-line2: #d8d2c6;
    --a-fg: #131313;
    --a-grey: #7a746c;
    --a-dim: #aaa399;
    --a-accent: #ff3b00;
    --a-green: #15803d;
    --a-amber: #b45309;
    --a-blue: #1d4ed8;
    --a-radius: 12px;
}

.admin-body {
    --bg: var(--a-bg); --fg: var(--a-fg); --accent: var(--a-accent); --red: var(--a-accent);
    --grey: var(--a-grey); --line: var(--a-line);
    display: grid;
    grid-template-columns: 236px 1fr;
    min-height: 100vh;
    background: var(--a-bg);
    color: var(--a-fg);
    font-family: 'Inter', ui-sans-serif, sans-serif;
    text-transform: none;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* ===== SIDEBAR ===== */
.a-side {
    background: var(--a-panel);
    border-right: 1px solid var(--a-line);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.a-logo {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 20px 18px; border-bottom: 1px solid var(--a-line);
    font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; font-size: 1.2rem; letter-spacing: -0.02em;
}
.a-logo .dot { color: var(--a-accent); }
.a-logo .tag { font-size: 0.56rem; color: var(--a-dim); margin-left: auto; letter-spacing: 2px; font-weight: 600; }
.a-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; flex: 1; }
.a-nav .grp { font-size: 0.62rem; letter-spacing: 1.5px; color: var(--a-dim); padding: 16px 10px 6px; font-weight: 600; }
.a-nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: 10px; cursor: pointer;
    color: var(--a-grey); font-weight: 600; letter-spacing: 0.01em; transition: all .15s ease;
    border: 1px solid transparent; font-size: 0.86rem;
}
.a-nav a:hover { color: var(--a-fg); background: var(--a-panel2); }
.a-nav a.active { color: var(--a-fg); background: var(--a-panel2); border-color: var(--a-line2); }
.a-nav a .ic { width: 16px; text-align: center; opacity: .85; }
.a-nav a .bdg { margin-left: auto; background: var(--a-accent); color: #fff; font-size: 0.62rem; padding: 1px 8px; border-radius: 20px; font-weight: 700; }
.a-foot { padding: 14px 12px; border-top: 1px solid var(--a-line); display: flex; flex-direction: column; gap: 4px; }
.a-foot a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; cursor: pointer; color: var(--a-grey); font-weight: 600; font-size: 0.86rem; }
.a-foot a:hover { color: var(--a-fg); background: var(--a-panel2); }
.a-foot a.danger:hover { color: var(--a-accent); }

/* ===== MAIN ===== */
.a-main { padding: 28px 32px 60px; min-width: 0; }
.a-topbar {
    display: flex; align-items: center; gap: 16px;
    margin-bottom: 26px; padding-bottom: 18px; border-bottom: 1px solid var(--a-line);
}
.a-topbar h1 { font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; font-size: 1.5rem; letter-spacing: -0.02em; }
.a-topbar .sub { color: var(--a-grey); font-size: 0.8rem; margin-top: 3px; }
.a-topbar .spacer { flex: 1; }
.a-topbar .hint { color: var(--a-dim); font-size: 0.74rem; }

/* ===== PANELS ===== */
.panel { display: none; }
.panel.active { display: block; animation: aFade .18s ease; }
@keyframes aFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ===== STAT CARDS ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat {
    background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--a-radius);
    padding: 18px 20px;
}
.stat .lbl { color: var(--a-grey); font-size: 0.66rem; letter-spacing: 1.5px; font-weight: 600; }
.stat .val { font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; font-size: 1.9rem; margin-top: 6px; line-height: 1; }
.stat .val .u { font-size: 0.9rem; color: var(--a-dim); font-weight: 600; }
.stat .sub { color: var(--a-dim); font-size: 0.66rem; margin-top: 6px; }
.stat.accent { border-color: color-mix(in srgb, var(--a-accent) 40%, var(--a-line)); }
.stat.accent .val { color: var(--a-accent); }

/* ===== CARDS ===== */
.a-card { background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--a-radius); margin-bottom: 18px; overflow: hidden; }
.a-card .h { padding: 15px 20px; border-bottom: 1px solid var(--a-line); display: flex; align-items: center; gap: 10px; font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; font-size: 0.85rem; }
.a-card .h .spacer { flex: 1; }
.a-card .b { padding: 18px 20px; }

/* ===== TOOLBAR ===== */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar .grow { flex: 1; }

/* ===== INPUTS ===== */
.a-input, .a-select, .a-textarea {
    width: 100%; background: var(--a-panel); color: var(--a-fg);
    border: 1.5px solid var(--a-line2); border-radius: 10px; padding: 10px 13px;
    font-family: inherit; font-size: 0.84rem; outline: none; transition: border .15s ease;
}
.a-input:focus, .a-select:focus, .a-textarea:focus { border-color: var(--a-fg); }
.a-input::placeholder { color: var(--a-dim); }
.a-textarea { min-height: 90px; resize: vertical; line-height: 1.6; }
.a-select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--a-grey) 50%), linear-gradient(135deg, var(--a-grey) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; cursor: pointer; }
.a-label { display: block; font-size: 0.66rem; letter-spacing: 1px; color: var(--a-grey); margin: 0 0 6px; font-weight: 600; }
.a-field { margin-bottom: 14px; }
.a-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.a-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ===== BUTTONS (pill) ===== */
.a-btn {
    display: inline-flex; align-items: center; gap: 8px; justify-content: center;
    padding: 10px 18px; border-radius: 9999px; cursor: pointer; font-weight: 600; font-family: inherit;
    font-size: 0.8rem; letter-spacing: 0.01em; border: 1.5px solid var(--a-line2);
    background: var(--a-panel); color: var(--a-fg); transition: all .15s ease; text-decoration: none;
}
.a-btn:hover { border-color: var(--a-fg); }
.a-btn.primary { background: var(--a-fg); color: #fff; border-color: var(--a-fg); }
.a-btn.primary:hover { background: var(--a-accent); border-color: var(--a-accent); }
.a-btn.accent { background: var(--a-accent); color: #fff; border-color: var(--a-accent); }
.a-btn.accent:hover { filter: brightness(1.08); }
.a-btn.ghost { background: transparent; }
.a-btn.sm { padding: 6px 12px; font-size: 0.72rem; }
.a-btn.xs { padding: 4px 10px; font-size: 0.68rem; }
.a-btn.danger { color: var(--a-accent); border-color: color-mix(in srgb, var(--a-accent) 40%, var(--a-line)); }
.a-btn.danger:hover { background: var(--a-accent); color: #fff; }
.a-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ===== TABLE ===== */
.a-table { width: 100%; border-collapse: collapse; }
.a-table th { text-align: left; font-size: 0.62rem; letter-spacing: 1.5px; color: var(--a-dim); padding: 10px 12px; border-bottom: 1px solid var(--a-line); font-weight: 600; }
.a-table td { padding: 12px; border-bottom: 1px solid var(--a-line); vertical-align: middle; }
.a-table tr:hover td { background: var(--a-panel2); }
.a-table .thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; background: var(--a-panel2); border: 1px solid var(--a-line2); display: inline-block; }
.a-table .thumb.ph { display: inline-flex; align-items: center; justify-content: center; font-family: 'Space Grotesk', sans-serif; color: var(--a-dim); font-size: 0.6rem; font-weight: 700; }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; padding: 3px 11px; border-radius: 20px; font-size: 0.64rem; font-weight: 600; letter-spacing: 0.02em; border: 1px solid transparent; }
.badge.green { color: var(--a-green); border-color: color-mix(in srgb, var(--a-green) 35%, transparent); background: color-mix(in srgb, var(--a-green) 9%, transparent); }
.badge.amber { color: var(--a-amber); border-color: color-mix(in srgb, var(--a-amber) 35%, transparent); background: color-mix(in srgb, var(--a-amber) 9%, transparent); }
.badge.blue { color: var(--a-blue); border-color: color-mix(in srgb, var(--a-blue) 35%, transparent); background: color-mix(in srgb, var(--a-blue) 9%, transparent); }
.badge.red { color: var(--a-accent); border-color: color-mix(in srgb, var(--a-accent) 35%, transparent); background: color-mix(in srgb, var(--a-accent) 9%, transparent); }
.badge.grey { color: var(--a-grey); border-color: var(--a-line2); background: var(--a-panel2); }

/* ===== ORDERS ===== */
.order-box { background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--a-radius); padding: 18px 20px; margin-bottom: 12px; }
.order-box .head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.order-box .oid { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 0.88rem; }
.order-box .when { color: var(--a-dim); font-size: 0.68rem; }
.order-box .spacer { flex: 1; }
.order-items { display: flex; flex-direction: column; gap: 5px; margin: 10px 0; }
.order-items .oi { display: flex; justify-content: space-between; color: var(--a-grey); font-size: 0.78rem; }
.order-total { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.1rem; margin-top: 10px; }
.order-cust { color: var(--a-grey); font-size: 0.74rem; margin-top: 8px; line-height: 1.7; }

/* ===== EMPTY ===== */
.a-empty { text-align: center; color: var(--a-dim); padding: 50px 20px; font-size: 0.82rem; }
.a-empty .big { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.6rem; color: var(--a-line2); margin-bottom: 8px; }

/* ===== TOAST ===== */
#toasts { position: fixed; bottom: 22px; right: 22px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: var(--a-panel); border: 1px solid var(--a-line2); border-left: 3px solid var(--a-green);
    padding: 13px 18px; border-radius: 12px; font-size: 0.8rem; font-weight: 600; min-width: 240px;
    box-shadow: 0 8px 30px rgba(0,0,0,.12); animation: toastIn .22s cubic-bezier(.2,.7,.2,1);
}
.toast.err { border-left-color: var(--a-accent); }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,20,20,.45); z-index: 300; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal { background: var(--a-panel); border: 1px solid var(--a-line2); border-radius: 16px; width: 100%; max-width: 640px; }
.modal .mh { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--a-line); font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 0.95rem; }
.modal .mh .x { margin-left: auto; cursor: pointer; color: var(--a-grey); font-size: 1.1rem; }
.modal .mb { padding: 22px; }
.modal .mf { display: flex; gap: 12px; padding: 18px 22px; border-top: 1px solid var(--a-line); justify-content: flex-end; }

/* ===== EDITOR ===== */
.editor-wrap { display: grid; grid-template-columns: 420px 1fr; gap: 16px; height: calc(100vh - 110px); min-height: 620px; }
.editor-controls {
    overflow-y: auto; background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--a-radius);
    padding: 16px; scrollbar-width: thin;
}
.editor-preview { position: relative; border: 1px solid var(--a-line); border-radius: var(--a-radius); background: var(--a-panel2); overflow: hidden; display: flex; flex-direction: column; }
.editor-preview .pv-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--a-panel); border-bottom: 1px solid var(--a-line); }
.editor-preview .pv-bar .url { color: var(--a-dim); font-size: 0.68rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-preview .pv-frame { flex: 1; display: flex; justify-content: center; align-items: flex-start; overflow: auto; padding: 14px; }
.editor-preview iframe { border: 1px solid var(--a-line2); background: #fff; transition: width .25s ease; height: 100%; width: 100%; border-radius: 8px; }
.editor-preview iframe.mobile { width: 390px; }

/* device toggle */
.seg { display: inline-flex; border: 1.5px solid var(--a-line2); border-radius: 9999px; overflow: hidden; }
.seg button { background: transparent; border: none; color: var(--a-grey); padding: 7px 15px; cursor: pointer; font-family: inherit; font-size: 0.74rem; font-weight: 600; }
.seg button.on { background: var(--a-fg); color: #fff; }

/* editor groups */
.ed-group { border: 1px solid var(--a-line2); border-radius: 12px; margin-bottom: 14px; background: var(--a-panel); }
.ed-group > .t { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 0.74rem; padding: 12px 14px; border-bottom: 1px solid var(--a-line); display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.ed-group > .t:hover { background: var(--a-panel2); }
.ed-group > .t .spacer { flex: 1; }
.ed-group > .t .chev { transition: transform .2s ease; color: var(--a-dim); font-size: 0.8rem; }
.ed-group.collapsed > .t { border-bottom: none; }
.ed-group.collapsed > .t .chev { transform: rotate(-90deg); }
.ed-group.collapsed > .bdy { display: none; }
.ed-group > .bdy { padding: 14px; }

/* section list items */
.section-item {
    display: flex; align-items: center; gap: 8px; padding: 10px 11px;
    border: 1px solid var(--a-line2); border-radius: 10px; margin-bottom: 7px; cursor: pointer;
    background: var(--a-panel); transition: all .13s ease;
}
.section-item:hover { border-color: var(--a-grey); }
.section-item.sel { border-color: var(--a-accent); background: color-mix(in srgb, var(--a-accent) 6%, var(--a-panel)); }
.section-item .drag { cursor: grab; color: var(--a-dim); font-size: 0.9rem; padding: 0 2px; }
.section-item .drag:active { cursor: grabbing; }
.section-item .idx { color: var(--a-dim); font-size: 0.66rem; width: 18px; }
.section-item .nm { flex: 1; font-weight: 600; font-size: 0.76rem; }
.section-item .typ { color: var(--a-dim); font-size: 0.62rem; letter-spacing: 1px; }
.section-item .icbtn { color: var(--a-grey); cursor: pointer; padding: 3px 6px; border-radius: 6px; font-size: 0.8rem; }
.section-item .icbtn:hover { background: var(--a-panel2); color: var(--a-fg); }
.section-item .icbtn.del:hover { color: var(--a-accent); }
.section-item.dragging { opacity: .45; }

/* list (repeatable) field */
.list-field { border: 1.5px dashed var(--a-line2); border-radius: 10px; padding: 10px; }
.list-item { border: 1px solid var(--a-line2); border-radius: 10px; padding: 10px; margin-bottom: 9px; background: var(--a-panel); position: relative; }
.list-item .li-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.list-item .li-head .lbl { font-size: 0.64rem; letter-spacing: 1px; color: var(--a-dim); font-weight: 600; }
.list-item .li-head .spacer { flex: 1; }
.list-item .li-x { cursor: pointer; color: var(--a-dim); font-size: 0.85rem; }
.list-item .li-x:hover { color: var(--a-accent); }

/* color inputs */
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.color-cell { display: flex; align-items: center; gap: 9px; border: 1px solid var(--a-line2); border-radius: 10px; padding: 7px 9px; }
.color-cell label { flex: 1; font-size: 0.64rem; color: var(--a-grey); letter-spacing: 1px; margin: 0; font-weight: 600; }
.color-cell input[type="color"] { width: 34px; height: 26px; padding: 0; border: 1px solid var(--a-line2); border-radius: 6px; background: transparent; cursor: pointer; }
.color-cell input[type="text"] { width: 72px; background: transparent; border: none; color: var(--a-fg); font-family: inherit; font-size: 0.72rem; outline: none; }

/* theme items */
.theme-item { display: flex; align-items: center; gap: 9px; border: 1px solid var(--a-line2); border-radius: 10px; padding: 9px 11px; margin-bottom: 7px; background: var(--a-panel); font-size: 0.74rem; }
.theme-item .dot { width: 15px; height: 15px; border-radius: 5px; border: 1px solid var(--a-line2); flex-shrink: 0; }
.theme-item .nm { flex: 1; font-weight: 600; }
.theme-item .a { cursor: pointer; padding: 4px 10px; border-radius: 9999px; font-size: 0.66rem; font-weight: 600; color: var(--a-grey); }
.theme-item .a:hover { background: var(--a-panel2); color: var(--a-fg); }
.theme-item .a.del:hover { color: var(--a-accent); }

/* save bar */
.save-bar { position: sticky; bottom: 0; margin-top: 16px; padding-top: 12px; background: linear-gradient(transparent, var(--a-panel) 30%); }
.save-bar .st { font-size: 0.66rem; color: var(--a-dim); margin-bottom: 8px; display: flex; align-items: center; gap: 7px; }
.save-bar .dot-ind { width: 7px; height: 7px; border-radius: 50%; background: var(--a-grey); display: inline-block; }
.save-bar .dot-ind.dirty { background: var(--a-amber); }
.save-bar .dot-ind.saved { background: var(--a-green); }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--a-bg); padding: 20px; }
.login-box { width: 100%; max-width: 380px; background: var(--a-panel); border: 1px solid var(--a-line2); border-radius: 16px; padding: 34px; box-shadow: 0 10px 40px rgba(0,0,0,.06); }

/* scrollbars */
.editor-controls::-webkit-scrollbar, .a-nav::-webkit-scrollbar { width: 8px; }
.editor-controls::-webkit-scrollbar-thumb, .a-nav::-webkit-scrollbar-thumb { background: var(--a-line2); border-radius: 4px; }

/* thumbnails */
.img-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.img-thumbs .th { position: relative; width: 70px; height: 70px; border: 1px solid var(--a-line2); border-radius: 10px; overflow: visible; }
.img-thumbs .th img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.img-thumbs .th .x { position: absolute; top: -7px; right: -7px; background: var(--a-accent); color: #fff; width: 18px; height: 18px; text-align: center; line-height: 18px; font-weight: bold; cursor: pointer; border-radius: 50%; font-size: 0.7rem; }

/* product checkboxes */
.check-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.check-pill { position: relative; }
.check-pill input { position: absolute; opacity: 0; pointer-events: none; }
.check-pill span { display: inline-block; padding: 8px 15px; border: 1.5px solid var(--a-line2); border-radius: 9999px; cursor: pointer; font-size: 0.74rem; font-weight: 600; transition: all .12s ease; color: var(--a-grey); }
.check-pill:hover span { border-color: var(--a-fg); color: var(--a-fg); }
.check-pill input:checked + span { background: var(--a-fg); border-color: var(--a-fg); color: #fff; }

.oid { font-family: 'Space Grotesk', 'Inter', sans-serif; }

@media (max-width: 980px) {
    .admin-body { grid-template-columns: 1fr; }
    .a-side { position: static; height: auto; }
    .a-nav { flex-direction: row; flex-wrap: wrap; }
    .editor-wrap { grid-template-columns: 1fr; height: auto; }
    .editor-controls { max-height: none; }
    #nlGrid { grid-template-columns: 1fr !important; }
}

/* ===== MOBILE (admin) ===== */
@media (max-width: 768px) {
    .admin-body { grid-template-columns: 1fr; }
    .a-side { position: sticky; top: 0; height: auto; z-index: 100; border-right: none; border-bottom: 1px solid var(--a-line); }
    .a-logo { padding: 12px 16px; font-size: 1.1rem; }
    .a-nav { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding: 8px 10px; gap: 6px; -webkit-overflow-scrolling: touch; }
    .a-nav .grp { display: none; }
    .a-nav a { flex-shrink: 0; white-space: nowrap; padding: 9px 13px; font-size: 0.76rem; border-radius: 9999px; }
    .a-nav a .bdg { margin-left: 6px; }
    .a-foot { flex-direction: row; padding: 8px 10px; border-top: 1px solid var(--a-line); }
    .a-foot a { flex: 1; justify-content: center; padding: 10px 6px; font-size: 0.74rem; border-radius: 9999px; }
    .a-main { padding: 16px 12px 60px; }
    .a-topbar { flex-wrap: wrap; padding-bottom: 14px; margin-bottom: 18px; }
    .a-topbar h1 { font-size: 1.2rem; }
    .a-topbar .sub { font-size: 0.72rem; }
    .a-card { overflow-x: auto; }
    .a-table { min-width: 560px; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat .val { font-size: 1.5rem; }
    .a-row, .a-row3 { grid-template-columns: 1fr; gap: 0; }
    .editor-wrap { grid-template-columns: 1fr; height: auto; }
    .editor-controls { max-height: none; padding: 12px; }
    .editor-preview { min-height: 62vh; }
    .modal-overlay { padding: 12px; }
    .modal { max-width: 100%; border-radius: 14px; }
    .modal .mb { padding: 16px; }
    .toolbar { flex-wrap: wrap; }
    #nlGrid { grid-template-columns: 1fr !important; }
    .save-bar { position: static; margin-top: 12px; }
    .order-box .head { gap: 8px; }
    .color-grid { grid-template-columns: 1fr; }
}
