:root {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --ink: #17151c;
    --muted: #6f6978;
    --surface: #ffffff;
    --surface-soft: #f7f7fb;
    --line: #e7e5ed;
    --pink: #f43f86;
    --violet: #7c3aed;
    --violet-soft: #f2ebff;
    --mint: #27ad78;
    --mint-soft: #e8f8f1;
    --red: #c33c53;
    --red-soft: #fff0f3;
    --shadow: 0 16px 50px rgba(47, 31, 63, .08);
    background: #f7f7fa;
    color: var(--ink);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 92% 0%, rgba(124, 58, 237, .08), transparent 28rem),
        radial-gradient(circle at 8% 100%, rgba(244, 63, 134, .08), transparent 30rem),
        #f7f7fa;
    color: var(--ink);
}

body, input, select, textarea, button { font: inherit; }

a { color: var(--violet); text-underline-offset: 3px; }
a:hover { color: #6225cf; }

h1, h2, h3 {
    color: var(--ink);
    letter-spacing: -.025em;
}

h2 { margin: 0 0 12px; font-size: clamp(1.2rem, 2vw, 1.55rem); }
p { line-height: 1.65; }
code { overflow-wrap: anywhere; }

.app-shell {
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 24px 18px;
    background: rgba(255, 255, 255, .92);
    border-right: 1px solid var(--line);
    backdrop-filter: blur(20px);
}

.brand,
.auth-brand {
    display: flex;
    align-items: center;
    gap: 13px;
    color: var(--ink);
    text-decoration: none;
}

.brand { margin: 0 6px 26px; }

.brand-logo,
.auth-brand img {
    flex: 0 0 auto;
    object-fit: cover;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 8px 24px rgba(65, 34, 91, .12);
}

.brand-logo { width: 66px; height: 66px; }
.brand span,
.auth-brand span { display: grid; gap: 2px; }
.brand strong,
.auth-brand strong { font-size: 1.14rem; letter-spacing: -.02em; }
.brand small,
.auth-brand small { color: var(--muted); font-size: .72rem; line-height: 1.25; }

.tree { display: grid; gap: 7px; }

.tree a,
.tree summary,
.link-button {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    min-height: 43px;
    padding: 10px 13px;
    border: 0;
    border-radius: 13px;
    color: #55505e;
    background: transparent;
    text-align: left;
    text-decoration: none;
    font-weight: 680;
    cursor: pointer;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

.tree a:hover,
.tree summary:hover,
.link-button:hover {
    color: var(--ink);
    background: #f4f2f8;
}

.tree a.active {
    color: #6929d5;
    background: linear-gradient(135deg, rgba(244, 63, 134, .10), rgba(124, 58, 237, .13));
    box-shadow: inset 0 0 0 1px rgba(124, 58, 237, .09);
}

.tree details { border-radius: 14px; }
.tree summary { list-style: none; color: #827b89; font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::after { content: "⌄"; margin-left: auto; font-size: 1rem; }
.tree details:not([open]) summary::after { content: "›"; }
.tree details a { min-height: 39px; margin: 2px 0 2px 12px; width: calc(100% - 12px); padding-left: 18px; font-size: .92rem; }
.tree form { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.nav-icon { width: 19px; text-align: center; color: var(--pink); font-size: 1rem; }

.content {
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: 36px clamp(20px, 4vw, 56px) 64px;
}

.auth-content {
    width: min(720px, calc(100% - 32px));
    margin: 42px auto;
}

.auth-brand {
    width: max-content;
    margin: 0 auto 28px;
}

.auth-brand img { width: 82px; height: 82px; }
.auth-brand strong { font-size: 1.35rem; }
.auth-brand small { font-size: .82rem; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.page-header h1 {
    margin: 0;
    font-size: clamp(1.65rem, 3.2vw, 2.45rem);
}

.user-chip {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, .86);
    font-size: .9rem;
    font-weight: 650;
}

.card {
    position: relative;
    margin-bottom: 20px;
    padding: clamp(21px, 3vw, 30px);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(255, 255, 255, .96);
    box-shadow: var(--shadow);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat {
    min-height: 126px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background:
        linear-gradient(145deg, rgba(255,255,255,.98), rgba(249,247,252,.98));
    box-shadow: 0 10px 30px rgba(47, 31, 63, .05);
    color: var(--muted);
    font-size: .9rem;
    font-weight: 680;
}

.stat::before {
    content: "";
    display: block;
    width: 34px;
    height: 4px;
    margin-bottom: 16px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--pink), var(--violet));
}

.stat strong {
    display: block;
    margin: 6px 0 2px;
    color: var(--ink);
    font-size: 1.18rem;
    line-height: 1.35;
}

.stat small { display: block; margin-top: 7px; }

.feature-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    background:
        radial-gradient(circle at 85% 20%, rgba(244, 63, 134, .13), transparent 16rem),
        linear-gradient(135deg, #fff, #faf7ff);
}

.feature-intro p { max-width: 760px; margin-bottom: 0; color: var(--muted); }

.feature-badge {
    display: grid;
    flex: 0 0 84px;
    width: 84px;
    height: 84px;
    place-items: center;
    border-radius: 25px;
    color: #fff;
    background: linear-gradient(145deg, var(--pink), var(--violet));
    box-shadow: 0 18px 35px rgba(124, 58, 237, .24);
    font-size: 2rem;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 9px;
    color: var(--pink);
    font-size: .75rem;
    font-weight: 850;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.usage-bar {
    height: 13px;
    margin: 18px 0 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #ece9f1;
}

.usage-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--pink), var(--violet));
    box-shadow: 0 0 18px rgba(124, 58, 237, .24);
    transition: width .2s ease;
}

.plan-pro {
    border-color: rgba(124, 58, 237, .22);
    background:
        radial-gradient(circle at 100% 0%, rgba(244, 63, 134, .10), transparent 24rem),
        linear-gradient(135deg, #fff, #f8f3ff);
}

.plan-price strong {
    color: var(--violet);
    font-size: 2.25rem;
    letter-spacing: -.04em;
}

label {
    display: block;
    margin: 18px 0 7px;
    color: #2c2931;
    font-weight: 740;
}

input:not([type]),
input[type=text],
input[type=email],
input[type=password],
input[type=url],
select,
textarea {
    width: 100%;
    border: 1px solid #d8d4df;
    border-radius: 13px;
    padding: 12px 14px;
    color: var(--ink);
    background: #fff;
    outline: 0;
    transition: border-color .16s ease, box-shadow .16s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(124, 58, 237, .58);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, .10);
}

textarea { min-height: 145px; resize: vertical; line-height: 1.55; }
small, .muted { color: var(--muted); line-height: 1.5; }

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.45;
}

.checkbox input {
    flex: 0 0 auto;
    width: 19px;
    height: 19px;
    margin: 2px 0 0;
    accent-color: var(--violet);
}

.toggle-row {
    margin: 0 0 20px;
    padding: 16px;
    border: 1px solid #e2deea;
    border-radius: 16px;
    background: var(--surface-soft);
}

.toggle-row span { display: grid; gap: 3px; }
.toggle-row strong { color: var(--ink); }
.toggle-row small { font-weight: 500; }

.quota-note {
    display: grid;
    gap: 4px;
    margin-top: 22px;
    padding: 16px 18px;
    border: 1px solid rgba(124, 58, 237, .16);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(244, 63, 134, .07), rgba(124, 58, 237, .08));
}

.quota-note strong { color: var(--violet); }
.quota-note span { color: var(--muted); font-size: .9rem; line-height: 1.5; }

.actions {
    display: flex;
    align-items: center;
    gap: 11px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.actions.compact { margin-top: 0; gap: 8px; }
.actions form { margin: 0; }

.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 11px 18px;
    border: 0;
    border-radius: 13px;
    color: #fff;
    background: linear-gradient(135deg, var(--pink), var(--violet));
    box-shadow: 0 10px 24px rgba(124, 58, 237, .18);
    font-weight: 780;
    text-decoration: none;
    cursor: pointer;
    transition: transform .17s ease, box-shadow .17s ease, opacity .17s ease;
}

.button:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(124, 58, 237, .25);
}

.button.secondary {
    color: #5e2eaa;
    background: #f2ebff;
    box-shadow: none;
}

.button.secondary:hover { color: #4d1e9c; background: #e9dcff; }
.button.danger { color: #fff; background: linear-gradient(135deg, #e25369, #b92d49); }
.button:disabled { cursor: not-allowed; opacity: .48; transform: none; }

.flash {
    margin: 0 0 18px;
    padding: 14px 17px;
    border: 1px solid transparent;
    border-radius: 15px;
    line-height: 1.5;
}

.flash.success { border-color: #c7eddc; color: #196c49; background: var(--mint-soft); }
.flash.error { border-color: #f4cdd4; color: #92283c; background: var(--red-soft); }
.flash.notice { border-color: #ded4f5; color: #5e398c; background: #f4effd; }

.status-active { color: var(--mint) !important; font-weight: 780; }
.status-inactive { color: #9b5663 !important; font-weight: 760; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); background: #faf9fc; font-size: .82rem; letter-spacing: .02em; }
tbody tr:hover { background: #fbfaff; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; }

.status {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 999px;
    color: #5c5662;
    background: #efedf2;
    font-size: .82rem;
    font-weight: 760;
}

.status.ok { color: #176746; background: var(--mint-soft); }
.status.off { color: #962a3f; background: var(--red-soft); }

.inline-form { display: inline; }
.auth-links { margin: 20px 0 0; text-align: center; color: var(--muted); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.search {
    display: flex;
    align-items: end;
    gap: 10px;
}

.search label { flex: 1; margin-top: 0; }

@media (max-width: 900px) {
    .app-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; padding: 16px; border-right: 0; border-bottom: 1px solid var(--line); }
    .brand { margin-bottom: 14px; }
    .brand-logo { width: 54px; height: 54px; }
    .tree { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tree details, .tree form { grid-column: span 2; }
    .tree details a { margin-left: 0; width: 100%; }
    .content { padding: 26px 16px 50px; }
}

@media (max-width: 620px) {
    .tree { display: block; }
    .tree > a, .tree > details, .tree > form { margin-bottom: 5px; }
    .page-header { align-items: flex-start; }
    .user-chip { display: none; }
    .grid { grid-template-columns: 1fr; }
    .split { grid-template-columns: 1fr; gap: 0; }
    .feature-intro { align-items: flex-start; }
    .feature-badge { flex-basis: 58px; width: 58px; height: 58px; border-radius: 18px; font-size: 1.5rem; }
    .card { border-radius: 20px; }
    .auth-content { margin-top: 26px; }
    .auth-brand img { width: 68px; height: 68px; }
    table { min-width: 760px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
