:root {
    --sidebar: #4b49f5;
    --sidebar-dark: #3d3bd6;
    --accent: #7e6df0;
    --accent-soft: #a99df5;
    --teal: #2ed8a7;
    --red: #f5455c;
    --ink: #1f1f2e;
    --muted: #7b7b93;
    --line: #eceef5;
    --bg: #f4f5f9;
    --card: #ffffff;
    --radius: 6px;
    --sidebar-w: 270px;
    --topbar-h: 62px;
}

* {
    box-sizing: border-box;
}

/* Any explicit `display` on an element beats the browser's default [hidden]
   rule, which silently breaks every element toggled via the hidden attribute.
   This makes `hidden` win everywhere. */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--sidebar);
    color: #fff;
    overflow-y: auto;
    z-index: 30;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar-h);
    padding: 0 24px;
    font-size: 22px;
    font-weight: 600;
}

.sidebar__logo {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .22);
    font-size: 17px;
    font-weight: 700;
}

.sidebar__profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 20px;
    padding: 14px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .12);
}

.sidebar__avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #d9d9ec center/cover no-repeat;
    flex: none;
}

.sidebar__avatar::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 1px;
    width: 10px;
    height: 10px;
    border: 2px solid var(--sidebar);
    border-radius: 50%;
    background: #2ed8a7;
}

.sidebar__name {
    font-weight: 600;
    line-height: 1.3;
}

.sidebar__role {
    font-size: 12px;
    opacity: .75;
}

.sidebar__heading {
    padding: 4px 24px 10px;
    font-size: 12px;
    letter-spacing: .04em;
    opacity: .65;
}

.sidebar__nav {
    list-style: none;
    margin: 0;
    padding: 0 0 30px;
}

.sidebar__nav a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 24px;
    font-size: 14.5px;
    opacity: .92;
    transition: background .15s;
}

.sidebar__nav a:hover,
.sidebar__nav a.is-active {
    background: rgba(255, 255, 255, .14);
    opacity: 1;
}

.sidebar__nav .dot {
    width: 15px;
    height: 15px;
    border: 2px solid currentColor;
    border-radius: 50%;
    flex: none;
    opacity: .85;
}

.sidebar__nav .caret {
    margin-left: auto;
    opacity: .7;
}

/* ---------- Topbar ---------- */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 26px;
    padding: 0 26px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    z-index: 20;
}

.topbar__help {
    font-weight: 600;
    white-space: nowrap;
}

.topbar__search {
    flex: 1;
    max-width: 540px;
    margin: 0 auto;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 3px;
    font: inherit;
    background: #fdfdff;
}

.topbar__search:focus {
    outline: 2px solid var(--accent-soft);
    outline-offset: -1px;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 22px;
    margin-left: auto;
}

.badge-btn {
    position: relative;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    color: var(--muted);
    background: none;
    border: 0;
    cursor: pointer;
}

.badge-btn span {
    position: absolute;
    top: -6px;
    right: -7px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 50%;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: grid;
    place-items: center;
}

.badge-btn.is-green span {
    background: var(--teal);
}

/* `display: grid` above beats the browser's [hidden] rule, so the count badge
   would render a red "0" instead of disappearing. Restate it explicitly. */
.badge-btn span[hidden] {
    display: none;
}

.topbar__user {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 0;
    cursor: pointer;
    font: inherit;
    color: var(--muted);
}

.topbar__user img,
.topbar__user .ph {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #d9d9ec;
    object-fit: cover;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
}

/* ---------- Layout ---------- */
.main {
    margin-left: var(--sidebar-w);
    padding: calc(var(--topbar-h) + 26px) 26px 40px;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 22px;
}

.page-head h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 500;
}

.page-head__links {
    display: flex;
    gap: 14px;
    color: var(--muted);
    font-size: 13.5px;
}

.page-head__right {
    margin-left: auto;
    display: flex;
    gap: 14px;
    color: var(--muted);
    font-size: 13.5px;
}

.page-head__right a:hover,
.page-head__links a:hover {
    color: var(--accent);
}

/* ---------- Cards ---------- */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 26px;
    box-shadow: 0 1px 2px rgba(31, 31, 46, .06);
}

.grid {
    display: grid;
    gap: 22px;
}

.grid--stats {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    align-items: center;
}

.grid--main {
    grid-template-columns: 2fr 1fr;
    margin-top: 22px;
}

.grid--thirds {
    grid-template-columns: repeat(3, 1fr);
    margin-top: 22px;
}

@media (max-width: 1100px) {

    .grid--main,
    .grid--thirds {
        grid-template-columns: 1fr;
    }
}

.stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.stat__value {
    font-size: 27px;
    font-weight: 600;
    line-height: 1.15;
}

.stat__label {
    color: var(--accent);
    font-size: 15px;
    margin: 2px 0 3px;
}

.stat__delta {
    color: var(--muted);
    font-size: 12.5px;
}

.stat__spark {
    width: 105px;
    height: 46px;
    flex: none;
}

.card__title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.card__sub {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.card__head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
}

.range {
    margin-left: auto;
    display: flex;
    gap: 16px;
    font-size: 13.5px;
    color: var(--muted);
}

.range button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.range button.is-active {
    color: var(--accent);
    font-weight: 600;
}

.totals {
    display: flex;
    flex-wrap: wrap;
    gap: 34px;
    align-items: flex-end;
    margin-bottom: 8px;
}

.totals__label {
    color: var(--muted);
    font-size: 13.5px;
}

.totals__value {
    font-size: 21px;
    font-weight: 600;
}

.totals__note {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

.legend {
    display: flex;
    gap: 20px;
    margin-left: auto;
    font-size: 13px;
    color: var(--muted);
}

.legend i {
    display: inline-block;
    width: 22px;
    height: 3px;
    border-radius: 2px;
    margin-right: 7px;
    vertical-align: middle;
}

.legend .dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 7px;
    vertical-align: middle;
}

.chart-wrap {
    position: relative;
    height: 330px;
}

.chart-wrap--sm {
    height: 130px;
}

.mini__label {
    color: var(--muted);
    font-size: 13.5px;
}

.mini__value {
    font-size: 27px;
    font-weight: 600;
}

.mini__delta {
    float: right;
    font-size: 13px;
}

.up {
    color: var(--teal);
}

.down {
    color: var(--red);
}

/* ---------- Toolbar ---------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    border: 0;
    border-radius: 3px;
    background: #e9eaf2;
    color: #4d4d66;
    font: inherit;
    cursor: pointer;
}

.pill--link {
    background: none;
    color: var(--accent);
}

.pill--primary {
    background: var(--accent);
    color: #fff;
}

/* ---------- Login ---------- */
.login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 30px;
    background: linear-gradient(135deg, var(--sidebar) 0%, #6f56f0 100%);
}

.login__card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 8px;
    padding: 44px 40px;
    box-shadow: 0 18px 50px rgba(20, 20, 60, .28);
}

.login__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
    font-size: 23px;
    font-weight: 600;
}

.login__brand .sidebar__logo {
    background: var(--sidebar);
}

.login__title {
    margin: 0 0 6px;
    font-size: 19px;
    font-weight: 600;
}

.login__sub {
    margin: 0 0 26px;
    color: var(--muted);
}

.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    margin-bottom: 7px;
    font-size: 13.5px;
    color: #4d4d66;
}

.field input[type="text"],
.field input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font: inherit;
    background: #fbfbfe;
}

.field input:focus {
    outline: 2px solid var(--accent-soft);
    outline-offset: -1px;
}

.field--check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13.5px;
}

.btn-block {
    width: 100%;
    padding: 13px;
    border: 0;
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    letter-spacing: .03em;
    cursor: pointer;
    transition: background .15s;
}

.btn-block:hover {
    background: #6d5ae8;
}

.alert {
    margin-bottom: 20px;
    padding: 12px 14px;
    border-radius: 4px;
    background: #fdecef;
    color: #b3243b;
    font-size: 13.5px;
}

.alert ul {
    margin: 0;
    padding-left: 18px;
}

.linkish {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

/* ---------- Flash ---------- */
.flash {
    margin-bottom: 20px;
    padding: 13px 16px;
    border-radius: var(--radius);
    background: #e6faf3;
    border: 1px solid #b6ecd9;
    color: #157a5b;
    font-size: 14px;
}

/* ---------- Filters ---------- */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.filters input[type="search"] {
    flex: 1;
    min-width: 220px;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font: inherit;
    background: #fbfbfe;
}

.filters select {
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font: inherit;
    background: #fbfbfe;
}

.filters input:focus,
.filters select:focus {
    outline: 2px solid var(--accent-soft);
    outline-offset: -1px;
}

/* ---------- Table ---------- */
.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th,
.table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.table th {
    color: var(--muted);
    font-weight: 600;
    font-size: 12.5px;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody tr:hover {
    background: #fafbff;
}

.table .ta-r {
    text-align: right;
}

.table .nowrap {
    white-space: nowrap;
}

.thumb {
    width: 62px;
    height: 42px;
    object-fit: cover;
    border-radius: 4px;
    background: #f1f2f7;
    display: block;
}

.thumb--empty {
    display: grid;
    place-items: center;
    color: var(--muted);
}

.muted-sm {
    color: var(--muted);
    font-size: 12.5px;
    margin-top: 2px;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 40px 14px;
}

.empty a {
    color: var(--accent);
}

.tag {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.tag--show {
    background: #e6faf3;
    color: #157a5b;
}

.tag--hide {
    background: #f2f3f8;
    color: #7b7b93;
}

.inline {
    display: inline;
}

.pill--sm {
    padding: 6px 13px;
    font-size: 13px;
}

.pill--danger {
    background: #fdecef;
    color: #b3243b;
}

.pill--danger:hover {
    background: #fbd9df;
}

.pager {
    margin-top: 20px;
}

.pager .pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.pager .page-link {
    display: inline-block;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--muted);
    font-size: 13.5px;
}

.pager .active .page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ---------- Forms ---------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

@media (max-width: 800px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.form-grid .field--wide {
    grid-column: 1 / -1;
}

.form-grid .field {
    margin: 0;
}

.form-grid input[type="text"],
.form-grid input[type="number"],
.form-grid input[type="file"],
.form-grid select,
.form-grid textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font: inherit;
    background: #fbfbfe;
    color: var(--ink);
}

.form-grid textarea {
    resize: vertical;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
    outline: 2px solid var(--accent-soft);
    outline-offset: -1px;
}

.req {
    color: var(--red);
}

.current-img {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 12px;
}

.current-img img {
    width: 108px;
    height: 72px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--line);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

/* ---------- API docs panel ---------- */
.docs {
    margin-bottom: 22px;
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    overflow: hidden;
}

.docs summary {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 16px 22px;
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.docs summary::-webkit-details-marker {
    display: none;
}

.docs summary::before {
    content: "\25B8";
    color: var(--accent);
    transition: transform .15s;
}

.docs[open] summary::before {
    transform: rotate(90deg);
}

.docs summary:hover {
    background: #fafbff;
}

.docs__title {
    font-weight: 600;
    font-size: 15px;
}

.docs__hint {
    color: var(--muted);
    font-size: 13px;
}

.docs__body {
    padding: 4px 22px 26px;
    border-top: 1px solid var(--line);
    font-size: 14.5px;
    line-height: 1.65;
}

.docs__lead {
    margin: 18px 0 0;
    color: var(--muted);
}

.docs__h {
    margin: 28px 0 10px;
    font-size: 15px;
    font-weight: 700;
}

.docs__body p {
    margin: 0 0 12px;
}

.docs__note {
    color: var(--muted);
    font-size: 13.5px;
}

.docs code {
    padding: 2px 6px;
    border-radius: 3px;
    background: #f2f3f8;
    color: #4b3fbb;
    font-family: ui-monospace, Consolas, "Courier New", monospace;
    font-size: 13px;
}

.docs__code {
    margin: 0 0 14px;
    padding: 16px 18px;
    border-radius: 6px;
    background: #1f2340;
    color: #e6e7f2;
    font-family: ui-monospace, Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
}

.docs__list {
    margin: 0;
    padding-left: 20px;
    display: grid;
    gap: 9px;
}

.docs__list code {
    font-size: 12.5px;
}

.table--docs td,
.table--docs th {
    padding: 9px 12px;
    font-size: 13.5px;
}

.table--docs code {
    font-size: 12.5px;
    white-space: nowrap;
}

.verb {
    display: inline-block;
    min-width: 60px;
    padding: 3px 9px;
    border-radius: 3px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .04em;
    text-align: center;
    color: #fff;
}

.verb--get {
    background: #2ed8a7;
}

.verb--post {
    background: #7e6df0;
}

.verb--put {
    background: #f0a12e;
}

.verb--del {
    background: #f5455c;
}

/* ---------- Manual price status tags ---------- */
.tag--st0 {
    background: #fff5e0;
    color: #a5700a;
}

.tag--st1 {
    background: #e6faf3;
    color: #157a5b;
}

.tag--st2 {
    background: #f2f3f8;
    color: #7b7b93;
}

.struck {
    text-decoration: line-through;
    color: var(--muted);
}

/* ---------- FAQ repeater ---------- */
.faq-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr auto;
    gap: 10px;
    margin-bottom: 10px;
}

@media (max-width: 800px) {
    .faq-row {
        grid-template-columns: 1fr;
    }
}

.faq-row input {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font: inherit;
    background: #fbfbfe;
    color: var(--ink);
}

.faq-row input:focus {
    outline: 2px solid var(--accent-soft);
    outline-offset: -1px;
}

.form-grid textarea {
    font-family: ui-monospace, Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6;
}

/* ---------- Notification bell ---------- */
.notif {
    position: relative;
}

.notif__panel {
    position: absolute;
    top: 36px;
    right: -8px;
    width: 340px;
    max-height: 440px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 16px 44px rgba(31, 31, 46, .18);
    z-index: 60;
}

/* `display: flex` above beats the browser's [hidden] rule, so the panel would
   stay on screen no matter what the JS set. Restate it explicitly. */
.notif__panel[hidden] {
    display: none;
}

.notif__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}

.notif__head-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.notif__head .linkish {
    color: var(--accent);
    font-size: 12.5px;
}

.notif__close {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: none;
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background .12s, color .12s;
}

.notif__close:hover {
    background: #f2f3f8;
    color: var(--ink);
}

.notif__list {
    overflow-y: auto;
    flex: 1;
}

.notif__item {
    display: block;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    transition: background .12s;
}

.notif__item:hover {
    background: #fafbff;
}

.notif__item strong {
    display: block;
    font-size: 14px;
}

.notif__route {
    display: block;
    color: var(--accent);
    font-size: 13px;
    margin: 1px 0 2px;
}

.notif__meta {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.notif__empty {
    margin: 0;
    padding: 26px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 13.5px;
}

.notif__all {
    display: block;
    padding: 12px 16px;
    text-align: center;
    border-top: 1px solid var(--line);
    color: var(--accent);
    font-size: 13.5px;
    font-weight: 600;
}

/* ---------- Dashboard extras ---------- */
.stat--link {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 4px;
    border-radius: var(--radius);
    transition: background .12s;
}

.stat--link:hover {
    background: #fafbff;
}

.mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.mini-table td {
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
}

.mini-table tr:last-child td {
    border-bottom: 0;
}

.mini-table .ta-r {
    text-align: right;
}

.bar {
    height: 6px;
    border-radius: 3px;
    background: var(--accent);
    min-width: 3px;
}

/* ---------- Detail view ---------- */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.detail {
    background: #fff;
    padding: 15px 18px;
}

.detail__label {
    display: block;
    color: var(--muted);
    font-size: 11.5px;
    letter-spacing: .05em;
    text-transform: uppercase;
    margin-bottom: 3px;
}

.detail__value {
    display: block;
    font-size: 15px;
    word-break: break-word;
}

.ref-chip {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    background: #f2f3f8;
    color: #4b3fbb;
    font-family: ui-monospace, Consolas, "Courier New", monospace;
    font-size: 13px;
}
