:root {
    --purple-950: #2a0f5d;
    --purple-900: #35106f;
    --purple-800: #43167e;
    --purple-700: #5a22a6;
    --purple-600: #6d2ed1;
    --purple-500: #8247e5;
    --purple-200: #dbcdf4;
    --purple-100: #eee8fb;
    --purple-50: #f7f4fd;
    --orange: #ffb000;
    --ink: #2e2f33;
    --muted: #73747b;
    --line: #dddddf;
    --surface: #ffffff;
    --page: #f1f1f2;
    --success: #169b62;
    --success-bg: #eaf8f1;
    --danger: #c9374b;
    --danger-bg: #fdecef;
    --disabled: #7a7b82;
    --disabled-bg: #efeff1;
    --shadow: 0 10px 30px rgba(38, 19, 67, .10);
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--page);
}

body {
    min-height: 100vh;
}

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

button,
input,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand strong {
    font-size: 20px;
    letter-spacing: -.02em;
}

.brand small {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    opacity: .78;
}

.brand-mark {
    position: relative;
    width: 34px;
    height: 34px;
    transform: rotate(-35deg);
}

.brand-mark span {
    position: absolute;
    width: 13px;
    height: 13px;
    border: 4px solid var(--orange);
    border-radius: 50%;
}

.brand-mark span:nth-child(1) {
    left: 2px;
    top: 2px;
    border-right-color: transparent;
}

.brand-mark span:nth-child(2) {
    right: 2px;
    top: 10px;
    border-left-color: transparent;
}

.brand-mark span:nth-child(3) {
    left: 7px;
    bottom: 0;
    border-top-color: transparent;
}

/* Login */
.login-body {
    display: grid;
    grid-template-columns: minmax(520px, 46%) 1fr;
    min-height: 100vh;
    background: #ececee;
}

.login-left {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 90px 40px 120px;
    background: #efeff1;
}

.login-brand {
    position: absolute;
    top: 28px;
    left: 44px;
}

.login-card {
    position: relative;
    z-index: 2;
    width: min(100%, 470px);
    padding: 38px 40px 42px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(31, 22, 43, .22);
}

.login-header h1 {
    margin: 3px 0 8px;
    font-size: 30px;
    line-height: 1.1;
}

.login-header p:last-child {
    margin: 0 0 26px;
    color: var(--muted);
}

.eyebrow {
    margin: 0 0 5px;
    color: #7c6f8c;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .02em;
}

.login-form,
.edit-form {
    display: grid;
    gap: 22px;
}

.login-form label,
.edit-form label {
    display: grid;
    gap: 8px;
}

.login-form label > span,
.edit-form label > span {
    color: #25262a;
    font-size: 14px;
    font-weight: 600;
}

input,
textarea {
    width: 100%;
    border: 1px solid #cfcfd3;
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

input {
    height: 42px;
    padding: 0 12px;
}

textarea {
    padding: 12px;
    resize: vertical;
}

input:focus,
textarea:focus {
    border-color: var(--purple-500);
    box-shadow: 0 0 0 3px rgba(130, 71, 229, .12);
}

input:disabled {
    color: #777;
    background: #f5f5f6;
}

.password-wrap {
    position: relative;
}

.password-wrap input {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    top: 0;
    right: 0;
    display: grid;
    place-items: center;
    width: 45px;
    height: 42px;
    border: 0;
    background: transparent;
    color: #666;
    cursor: pointer;
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

.form-alert,
.success-banner {
    margin-bottom: 20px;
    padding: 12px 14px;
    border-radius: 7px;
    font-size: 14px;
}

.form-alert {
    color: #8d2634;
    background: var(--danger-bg);
    border: 1px solid #f2c8cf;
}

.success-banner {
    margin-top: -8px;
    color: #116b45;
    background: var(--success-bg);
    border: 1px solid #bce7d2;
}

.primary-button,
.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 18px;
    border-radius: 6px;
    font-weight: 650;
    cursor: pointer;
    transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.primary-button {
    border: 1px solid var(--purple-600);
    background: var(--purple-600);
    color: #fff;
}

.primary-button:hover {
    background: var(--purple-700);
}

.primary-button:active,
.secondary-button:active {
    transform: translateY(1px);
}

.primary-button.full {
    width: 100%;
    margin-top: 8px;
}

.secondary-button {
    border: 1px solid #d1c8df;
    background: #fff;
    color: var(--purple-700);
}

.secondary-button:hover {
    border-color: var(--purple-500);
    background: var(--purple-50);
}

.secondary-button.small {
    min-height: 34px;
    padding: 0 13px;
    font-size: 13px;
}

.login-right {
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--purple-800);
    color: #fff;
}

.clock-mark {
    position: relative;
    width: min(34vw, 340px);
    aspect-ratio: 1;
    border: 32px solid #fff;
    border-radius: 50%;
}

.clock-mark::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transform: translate(-50%, -50%);
}

.clock-hand {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 17px;
    background: #fff;
    transform-origin: 50% 0;
}

.clock-hand.hour {
    height: 86px;
    transform: translate(-50%, 0) rotate(0deg);
}

.clock-hand.minute {
    height: 112px;
    transform: translate(-50%, 0) rotate(-43deg);
}

.login-right-copy {
    position: absolute;
    left: 50px;
    bottom: 44px;
    display: grid;
    gap: 5px;
}

.login-right-copy span {
    opacity: .65;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .13em;
}

.login-right-copy strong {
    max-width: 390px;
    font-size: 22px;
}

.mesh {
    position: absolute;
    left: -5%;
    right: -10%;
    bottom: -80px;
    height: 210px;
    opacity: .36;
    background-image:
        linear-gradient(12deg, transparent 46%, rgba(130, 71, 229, .55) 47%, transparent 48%),
        linear-gradient(168deg, transparent 46%, rgba(0, 194, 255, .45) 47%, transparent 48%);
    background-size: 28px 28px;
    transform: skewY(-4deg);
}

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

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 28px 18px 22px;
    background: var(--purple-800);
    color: #fff;
}

.brand-sidebar {
    padding: 0 14px 26px;
}

.brand-sidebar strong {
    font-size: 17px;
}

.sidebar-search {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 44px;
    margin: 0 5px 14px;
    padding: 0 12px;
    border-bottom: 1px solid rgba(255,255,255,.14);
    color: rgba(255,255,255,.45);
}

.sidebar-search svg,
.nav-item svg,
.logout-button svg {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
}

.sidebar-nav {
    display: grid;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 13px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 8px;
    color: rgba(255,255,255,.92);
    font-size: 14px;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255,255,255,.10);
}

.nav-item.active {
    color: #fff;
    font-weight: 650;
}

.nav-item.muted {
    opacity: .7;
    cursor: default;
}

.sidebar-bottom {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,.13);
}

.admin-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px 14px;
}

.avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #d7d3de;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.admin-meta {
    min-width: 0;
    display: grid;
}

.admin-meta strong {
    font-size: 13px;
}

.admin-meta small {
    overflow: hidden;
    margin-top: 2px;
    color: rgba(255,255,255,.65);
    font-size: 10px;
    text-overflow: ellipsis;
}

.logout-button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 0 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: rgba(255,255,255,.8);
    cursor: pointer;
}

.logout-button:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.main-content {
    min-width: 0;
    padding: 34px 44px 60px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-header h1 {
    margin: 3px 0 5px;
    font-size: 30px;
    line-height: 1.15;
    letter-spacing: -.025em;
}

.page-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.back-link {
    display: inline-flex;
    margin-bottom: 14px;
    color: var(--purple-600);
    font-size: 13px;
    font-weight: 650;
}

.title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Cards / panels */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stats-grid.stats-six {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stat-card {
    min-width: 0;
    padding: 19px 20px;
    border: 1px solid #e0dfe3;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 3px 10px rgba(35, 29, 43, .03);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 29px;
    letter-spacing: -.03em;
}

.stat-card small {
    display: block;
    margin-top: 5px;
    color: #92939a;
    font-size: 11px;
}

.panel {
    overflow: hidden;
    border: 1px solid #e1e0e4;
    border-radius: var(--radius);
    background: #fff;
    box-shadow: 0 5px 18px rgba(34, 22, 47, .04);
}

.panel-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px 10px;
}

.search-field {
    position: relative;
    width: min(100%, 420px);
}

.search-field svg {
    position: absolute;
    left: 13px;
    top: 50%;
    width: 18px;
    height: 18px;
    color: #a2a3a8;
    transform: translateY(-50%);
}

.search-field input {
    height: 38px;
    padding-left: 39px;
    border-radius: 6px;
    font-size: 13px;
    font-style: italic;
}

.toolbar-note {
    color: #98999f;
    font-size: 12px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

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

.data-table th {
    padding: 12px 16px;
    border-top: 1px solid #ddd5ea;
    border-bottom: 1px solid #ddd5ea;
    background: #f1ecfa;
    color: #29282c;
    text-align: left;
    font-weight: 650;
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #dedee0;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: #fcfbfe;
}

.data-table.compact td,
.data-table.compact th {
    padding: 11px 14px;
}

.project-name {
    display: inline-flex;
    align-items: center;
    gap: 11px;
}

.project-name strong,
.project-name small {
    display: block;
}

.project-name strong {
    font-size: 14px;
}

.project-name small {
    margin-top: 3px;
    color: #9a9aa0;
    font-size: 11px;
}

.project-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--purple-100);
    color: var(--purple-700);
}

.project-icon svg {
    width: 20px;
    height: 20px;
}

.source-code,
code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.source-code {
    display: inline-block;
    padding: 5px 8px;
    border-radius: 5px;
    background: #f4f2f7;
    color: #544660;
    font-size: 12px;
}

.data-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.data-badges span,
.entity-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: #f1f1f3;
    color: #66676d;
    font-size: 11px;
    white-space: nowrap;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 27px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}

.status-pill i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.status-pill.active {
    color: var(--success);
    background: var(--success-bg);
}

.status-pill.inactive {
    color: var(--danger);
    background: var(--danger-bg);
}

.status-pill.disabled {
    color: var(--disabled);
    background: var(--disabled-bg);
}

.table-action {
    width: 1%;
    white-space: nowrap;
}

.panel-footer {
    padding: 14px 20px;
    color: #85868c;
    font-size: 12px;
}

.empty-state {
    display: grid;
    place-items: center;
    gap: 5px;
    min-height: 90px;
    color: #8c8d93;
    text-align: center;
}

.empty-state strong {
    color: #4c4d51;
}

/* Details */
.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
    gap: 20px;
}

.section-space {
    margin-top: 20px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 22px 12px;
}

.section-heading h2 {
    margin: 3px 0 0;
    font-size: 20px;
}

.edit-form {
    padding: 10px 22px 24px;
}

.edit-form label small {
    color: #8a8b91;
    font-size: 11px;
    font-weight: 400;
}

.toggle-row {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 0;
    border-top: 1px solid #ececef;
    border-bottom: 1px solid #ececef;
}

.toggle-row > span {
    display: grid;
    gap: 4px;
}

.toggle-input {
    appearance: none;
    position: relative;
    flex: 0 0 auto;
    width: 44px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: #c8c8cd;
    cursor: pointer;
    transition: background .18s ease;
}

.toggle-input::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.18);
    transition: transform .18s ease;
}

.toggle-input:checked {
    background: var(--purple-600);
}

.toggle-input:checked::after {
    transform: translateX(20px);
}

.info-list {
    margin: 0;
    padding: 2px 22px 20px;
}

.info-list div {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 0;
    border-bottom: 1px solid #ececef;
}

.info-list dt {
    color: #84858a;
    font-size: 12px;
}

.info-list dd {
    margin: 0;
    color: #303136;
    font-size: 12px;
    font-weight: 600;
    text-align: right;
}

.status-explainer {
    margin: 0 22px 22px;
    padding: 14px;
    border-radius: 8px;
    background: var(--purple-50);
    color: #5b4d69;
}

.status-explainer strong {
    font-size: 12px;
}

.status-explainer p {
    margin: 6px 0 0;
    font-size: 11px;
    line-height: 1.5;
}

.simple-list {
    padding: 0 22px 18px;
}

.simple-list > div:not(.empty-state) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 13px 0;
    border-bottom: 1px solid #ececef;
}

.simple-list strong {
    font-size: 13px;
}

.simple-list span {
    color: #898a90;
    font-size: 11px;
}

.not-found {
    display: grid;
    justify-items: start;
    max-width: 520px;
    margin: 70px auto;
    padding: 40px;
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
}

.not-found h1 {
    margin: 0;
}

.not-found p:not(.eyebrow) {
    margin: 10px 0 24px;
    color: var(--muted);
}

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

    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 960px) {
    .login-body {
        grid-template-columns: 1fr;
    }

    .login-right {
        display: none;
    }

    .app-body {
        grid-template-columns: 76px minmax(0, 1fr);
    }

    .sidebar {
        padding-left: 10px;
        padding-right: 10px;
    }

    .brand-sidebar div:last-child,
    .sidebar-search span,
    .nav-item span,
    .admin-meta,
    .logout-button:not(:hover) {
        font-size: 0;
    }

    .brand-sidebar,
    .sidebar-search,
    .nav-item,
    .admin-card,
    .logout-button {
        justify-content: center;
    }

    .main-content {
        padding: 28px 24px 50px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .login-left {
        padding: 90px 18px 40px;
    }

    .login-brand {
        left: 22px;
    }

    .login-card {
        padding: 30px 24px 34px;
    }

    .app-body {
        display: block;
    }

    .sidebar {
        position: static;
        display: none;
    }

    .main-content {
        padding: 22px 14px 40px;
    }

    .stats-grid.stats-six {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .panel-toolbar,
    .page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .search-field {
        width: 100%;
    }
}
