:root {
    --primary: #6e3ff3;
    --primary-light: #f4f0ff;
    --background: #f8f6fd;
    --surface: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #00a846;
    --warning: #dc8500;
    --danger: #e72c48;
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background: var(--background);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Myanmar Text", sans-serif;
    line-height: 1.5;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 76px;
    padding: 0 22px;
    color: var(--primary);
    font-size: 20px;
    font-weight: 800;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
}

.brand-mark,
.avatar,
.empty-mark {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    font-size: 13px;
}

.nav {
    display: grid;
    gap: 6px;
    padding: 20px 12px;
}

.nav-link {
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.nav-link:hover,
.nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-link.disabled {
    cursor: not-allowed;
    opacity: .55;
}

.sidebar-footer {
    margin-top: auto;
    padding: 20px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
}

.main {
    margin-left: var(--sidebar-width);
}

.topbar {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 30px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.eyebrow {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

h1 {
    margin-top: 2px;
    font-size: 18px;
}

.profile {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 700;
}

.profile-copy {
    display: grid;
    min-width: 0;
}

.profile-copy strong {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.profile-copy small {
    color: var(--muted);
    font-size: 11px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 12px;
}

.content {
    width: min(1440px, 100%);
    padding: 28px 30px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.metric-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.metric-card {
    position: relative;
    min-height: 132px;
    padding: 20px;
    overflow: hidden;
}

.metric-card p {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.metric-card strong {
    display: block;
    margin-top: 16px;
    font-size: 30px;
}

.metric-indicator {
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: var(--primary);
}

.metric-indicator.success { background: var(--success); }
.metric-indicator.warning { background: var(--warning); }
.metric-indicator.danger { background: var(--danger); }

.panel {
    margin-top: 20px;
    min-height: 360px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 { font-size: 16px; }
.panel-header p { margin-top: 3px; color: var(--muted); font-size: 12px; }

.button {
    min-height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: #5425d6; }
.button-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.button-secondary:hover { background: #f1f5f9; }
.button-block { width: 100%; min-height: 46px; }

.empty-state {
    min-height: 280px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    padding: 30px;
    text-align: center;
}

.empty-mark {
    width: 54px;
    height: 54px;
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary);
}

.empty-state h3 { margin-top: 6px; font-size: 17px; }
.empty-state p { max-width: 420px; color: var(--muted); font-size: 13px; line-height: 1.6; }

@media (max-width: 900px) {
    .sidebar { width: 210px; }
    .main { margin-left: 210px; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
    .sidebar { display: flex; }
    .main { margin-left: 0; }
    .topbar, .content { padding-left: 16px; padding-right: 16px; }
    .profile span:last-child { display: none; }
    .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
    .metric-card { min-height: 118px; padding: 16px; }
    .panel-header { align-items: flex-start; flex-direction: column; }
}

.icon-button {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.icon-button:hover { background: var(--primary-light); color: var(--primary); }
.menu-button { display: none; }

.alert {
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.55;
}

.alert-success { color: #176b38; background: #eaf8ef; border-color: #bce8ca; }
.alert-error { color: #a71932; background: #fff0f2; border-color: #f5c2cb; }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--background);
}

.login-panel {
    width: min(420px, 100%);
    padding: 34px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 14px 38px rgba(30, 41, 59, .08);
}

.login-brand {
    display: grid;
    justify-items: center;
    color: var(--primary);
}

.login-mark {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    margin-bottom: 10px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 16px;
    font-weight: 900;
}

.login-brand strong { font-size: 24px; }
.login-brand > span:last-child { color: var(--muted); font-size: 12px; font-weight: 600; }

.login-heading { margin: 28px 0 22px; text-align: center; }
.login-heading h1 { font-size: 19px; }
.login-heading p { margin-top: 5px; color: var(--muted); font-size: 13px; }

.form-stack { display: grid; gap: 16px; }
.field { display: grid; align-content: start; gap: 6px; min-width: 0; }
.field > span:first-child { color: var(--text); font-size: 13px; font-weight: 700; }
.field small { color: var(--muted); font-size: 11px; line-height: 1.45; }
.field-error { color: var(--danger) !important; font-size: 11px !important; font-weight: 600 !important; }

.field input,
.field select {
    width: 100%;
    height: 44px;
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    outline: 0;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 14px;
}

.field input:focus,
.field select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(110, 63, 243, .12);
}

.uppercase { text-transform: uppercase; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 48px; }
.password-toggle {
    position: absolute;
    inset: 4px 4px 4px auto;
    width: 36px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.password-toggle:hover { background: var(--primary-light); color: var(--primary); }
.configuration-note { color: var(--muted); text-align: center; font-size: 13px; line-height: 1.6; }
code { padding: 2px 5px; border-radius: 4px; background: #f1f5f9; font-size: .9em; }

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

.page-heading h2 { font-size: 18px; }
.page-heading p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.panel-table { margin-top: 0; }

.promo-control { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 24px; align-items: center; margin-bottom: 18px; padding: 24px; color: #fff; background: linear-gradient(120deg, #5b2be0, #6e3ff3 55%, #2878e8); border-radius: 8px; box-shadow: 0 12px 30px rgba(75, 42, 190, .18); }
.promo-control h2 { margin: 4px 0 7px; font-size: 21px; }
.promo-control p { max-width: 720px; color: rgba(255,255,255,.84); font-size: 12px; line-height: 1.6; }
.promo-control .eyebrow { color: rgba(255,255,255,.72); }
.promo-count, .promo-badge { display: inline-flex; align-items: center; margin-top: 12px; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.promo-count { color: #fff; background: rgba(255,255,255,.17); }
.promo-badge { margin-top: 0; color: #5b2be0; background: #eee8ff; }
.promo-actions { display: grid; gap: 10px; }
.promo-enable, .promo-end { width: 100%; justify-content: center; font-weight: 800; }
.promo-enable { color: #075e43; background: #d6fff0; }
.promo-end { color: #4c268d; background: #fff; }
.promo-end-form { display: grid; gap: 8px; }
.promo-end-form label { display: grid; gap: 4px; color: rgba(255,255,255,.84); font-size: 10px; }
.promo-end-form input { min-height: 38px; border: 0; border-radius: 6px; padding: 0 10px; }
.workspace-promo-form { display: grid; grid-template-columns: minmax(145px,1fr) 136px 34px; gap: 6px; align-items: center; min-width: 330px; }
.workspace-promo-form select, .workspace-promo-form input { min-height: 34px; padding: 5px 7px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: 11px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; text-align: left; }
th { padding: 12px 16px; background: #f8fafc; color: var(--muted); font-size: 12px; font-weight: 700; }
td { padding: 15px 16px; border-top: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
td strong, td small { display: block; }
td small { margin-top: 3px; color: var(--muted); font-size: 11px; }
tbody tr:hover td { background: #fcfbff; }

.status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.status-active { color: #176b38; background: #eaf8ef; }
.status-inactive { color: #475569; background: #eef2f6; }
.status-trial, .status-grace_period { color: #955600; background: #fff4d6; }
.status-suspended, .status-cancelled { color: #a71932; background: #fff0f2; }
.status-submitted { color: #955600; background: #fff4d6; }
.status-verified { color: #176b38; background: #eaf8ef; }
.status-rejected, .status-void { color: #a71932; background: #fff0f2; }
.panel-footer { padding: 14px 18px; border-top: 1px solid var(--border); text-align: right; }
.panel-footer a { color: var(--primary); font-size: 12px; font-weight: 700; text-decoration: none; }

.workspace-dialog {
    width: min(760px, calc(100% - 32px));
    max-height: calc(100vh - 32px);
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    box-shadow: 0 24px 60px rgba(15, 23, 42, .2);
}

.workspace-dialog::backdrop { background: rgba(15, 23, 42, .48); }
.workspace-form { display: grid; max-height: calc(100vh - 32px); }
.dialog-header, .dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; }
.dialog-header { border-bottom: 1px solid var(--border); }
.dialog-header h2 { font-size: 17px; }
.dialog-header p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.dialog-body { padding: 20px; overflow-y: auto; }
.dialog-footer { justify-content: flex-end; border-top: 1px solid var(--border); }

fieldset { min-width: 0; margin: 0 0 24px; padding: 0; border: 0; }
fieldset:last-child { margin-bottom: 0; }
legend { width: 100%; margin-bottom: 13px; padding-bottom: 8px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 800; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field-wide { grid-column: 1 / -1; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, .8fr); gap: 20px; align-items: start; }
.admin-grid .panel { margin-top: 0; min-height: 0; }
.panel-body { padding: 20px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form select, .inline-form input { min-height: 38px; padding: 7px 10px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; }
.button-danger { background: var(--danger); color: #fff; }
.button-small { min-height: 34px; padding: 0 11px; font-size: 12px; }
.check-row { display: flex; flex-wrap: wrap; gap: 12px; }
.check-row label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.usage-copy { color: var(--muted); font-size: 12px; white-space: nowrap; }
.proof-link { color: var(--primary); font-weight: 700; text-decoration: none; }
.account-form { margin-top: 20px; }

.sidebar-backdrop { display: none; }

@media (max-width: 680px) {
    .promo-control { grid-template-columns: 1fr; padding: 18px; }
    .sidebar {
        width: min(280px, 84vw);
        transform: translateX(-102%);
        transition: transform .2s ease;
        z-index: 30;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.visible {
        position: fixed;
        inset: 0;
        z-index: 20;
        display: block;
        border: 0;
        background: rgba(15, 23, 42, .42);
    }
    .menu-button { display: inline-grid; }
    .topbar { min-height: 68px; padding: 10px 14px; }
    .content { padding: 18px 14px 28px; }
    .profile-copy { display: none; }
    .metrics { grid-template-columns: 1fr 1fr; }
    .page-heading { align-items: stretch; flex-direction: column; }
    .page-heading .button { width: 100%; }
    .panel-header { flex-direction: row; align-items: center; }
    .form-grid { grid-template-columns: 1fr; }
    .admin-grid { grid-template-columns: 1fr; }
    .field-wide { grid-column: auto; }
    .dialog-header, .dialog-body, .dialog-footer { padding-left: 16px; padding-right: 16px; }
    .dialog-footer .button { flex: 1; padding-left: 10px; padding-right: 10px; }
    .login-page { padding: 14px; }
    .login-panel { padding: 26px 20px; }
}

@media (max-width: 400px) {
    .metrics { grid-template-columns: 1fr; }
    .metric-card { min-height: 104px; }
}
