:root {
    color-scheme: light;
    --ink: #172019;
    --muted: #6e786f;
    --line: #e2e8e2;
    --paper: #f4f7f3;
    --white: #fff;
    --lime: #c9f16b;
    --lime-dark: #668625;
    --sidebar: #172019;
    --danger: #b33f3a;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 30px 22px 22px; background: var(--sidebar); color: #fff; }
.brand { color: var(--ink); font-size: 30px; font-weight: 850; letter-spacing: -1.8px; line-height: 1; text-decoration: none; }
.brand span, .accent { color: var(--lime-dark); }
.brand-light { color: #fff; }
.brand-light span { color: var(--lime); }
.sidebar-label { margin: 45px 12px 12px; color: #849086; font-size: 10px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; }
.sidebar-nav { display: grid; gap: 5px; }
.sidebar-nav a { display: flex; align-items: center; gap: 12px; padding: 12px 13px; border-radius: 9px; color: #aeb8b0; font-size: 14px; font-weight: 700; text-decoration: none; }
.sidebar-nav a:hover, .sidebar-nav a.active { background: rgba(255,255,255,.09); color: #fff; }
.sidebar-nav a.active span { color: var(--lime); }
.sidebar-user { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.1); }
.avatar { display: grid; flex: 0 0 auto; place-items: center; width: 36px; height: 36px; background: var(--lime); border-radius: 50%; color: var(--ink); font-size: 13px; font-weight: 850; }
.sidebar-user strong, .sidebar-user span { display: block; max-width: 105px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user strong { font-size: 12px; }
.sidebar-user span { margin-top: 3px; color: #8f9a91; font-size: 10px; }
.sidebar-user button { padding: 5px; background: transparent; border: 0; color: #89958c; font-size: 18px; }
.main-panel { min-width: 0; }
.mobile-header { display: none; }
.page-wrap { width: min(1380px, calc(100% - 64px)); margin: 0 auto; padding: 43px 0 70px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 30px; margin-bottom: 30px; }
.page-header h1 { margin: 8px 0 4px; font-size: 38px; letter-spacing: -2px; }
.page-header > div > p:last-child, .panel-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.eyebrow { margin: 0; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: 1.35px; text-transform: uppercase; }
.primary-button { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 48px; padding: 13px 17px; background: var(--ink); border: 0; border-radius: 9px; color: #fff; font-weight: 750; text-decoration: none; }
.primary-button:hover { background: #2d3930; }
.primary-button.compact { width: auto; min-height: 42px; padding: 10px 16px; }
.notice { margin-bottom: 22px; padding: 13px 16px; background: #eaf8cb; border: 1px solid #d2e99e; border-radius: 9px; font-size: 13px; font-weight: 650; }
.danger-notice { background: #fff0ef; border-color: #f0c8c5; color: var(--danger); }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 20px; }
.stats-grid article { padding: 22px; background: #fff; border: 1px solid var(--line); border-radius: 13px; }
.stats-grid span, .stats-grid strong { display: block; }
.stats-grid span { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.stats-grid strong { margin-top: 8px; font-size: 29px; letter-spacing: -1.3px; }
.panel { margin-bottom: 20px; padding: 24px; background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 10px 30px rgba(29,45,33,.035); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.panel-heading h2 { margin: 0 0 5px; font-size: 19px; letter-spacing: -.6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid .span-2 { grid-column: span 2; }
.user-form { grid-template-columns: repeat(3, 1fr); }
label { display: block; margin: 0 0 8px; font-size: 11px; font-weight: 800; }
label span { color: #949c96; font-weight: 500; }
input, select, textarea { width: 100%; padding: 0 13px; background: #fafcf9; border: 1px solid #dce3dc; border-radius: 8px; color: var(--ink); outline: none; transition: .15s; }
input, select { height: 46px; }
textarea { padding-top: 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #91b545; box-shadow: 0 0 0 4px rgba(201,241,107,.25); }
.form-action { display: flex; align-items: flex-end; }
.error { margin: 6px 0 0; color: var(--danger); font-size: 11px; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 18px; color: var(--muted); font-weight: 650; }
.check-row input { width: 16px; height: 16px; accent-color: var(--ink); }
.admin-check { align-self: center; margin: 24px 0 0; }
.table-wrap { width: 100%; overflow-x: auto; }
#links-table { width: 100% !important; }
table.dataTable thead th { color: #7b857d; font-size: 10px; font-weight: 850; letter-spacing: .5px; text-transform: uppercase; }
table.dataTable tbody td { vertical-align: middle; font-size: 12px; }
.dt-container .dt-search input { min-width: 290px; height: 40px; margin: 0 0 14px; }
.dt-container .dt-length select { height: 38px; }
.dt-container .dt-info, .dt-container .dt-paging { margin-top: 13px; color: var(--muted); font-size: 11px; }
.short-cell { display: flex; align-items: center; gap: 7px; }
.short-cell a { color: #435d16; font-weight: 800; text-decoration: none; white-space: nowrap; }
.short-cell button { padding: 4px 7px; background: #eef2eb; border: 0; border-radius: 5px; color: var(--ink); font-size: 9px; font-weight: 750; }
.truncate { display: block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode, .status, .role { display: inline-block; padding: 5px 8px; border-radius: 99px; font-size: 9px; font-weight: 850; text-transform: uppercase; white-space: nowrap; }
.mode.direct, .status.active { background: #eaf8cb; color: #55751c; }
.mode.landing { background: #eef1ef; color: #58635b; }
.status.expired { background: #fff0ef; color: #a63d37; }
.icon-button { width: 28px; height: 28px; background: #f3f5f2; border: 0; border-radius: 6px; }
.icon-button.danger { color: var(--danger); font-size: 18px; }
.table-link { color: #435d16; font-weight: 800; text-decoration: none; white-space: nowrap; }
.device-badge { display: inline-block; padding: 5px 8px; background: #eef1ef; border-radius: 99px; color: #59645d; font-size: 9px; font-weight: 850; text-transform: uppercase; }
.click-count-link { display: inline-grid; min-width: 28px; height: 28px; place-items: center; background: #eef4e4; border-radius: 7px; color: #4f7018; font-weight: 850; text-decoration: none; }
.click-count-link:hover { background: var(--lime); color: var(--ink); }
.filter-label { display: inline-block; margin-left: 8px; padding: 5px 8px; background: #eaf8cb; border-radius: 99px; color: #55751c; font-size: 9px; font-weight: 850; vertical-align: middle; }
.clear-filter { margin-left: 5px; color: var(--lime-dark); font-weight: 750; }
.user-list { display: grid; gap: 9px; }
.user-row { border: 1px solid var(--line); border-radius: 10px; }
.user-row summary { display: grid; grid-template-columns: 38px 1fr auto auto; gap: 12px; align-items: center; padding: 14px; list-style: none; cursor: pointer; }
.user-row summary::-webkit-details-marker { display: none; }
.user-row summary strong, .user-row summary span { display: block; }
.user-row summary strong { font-size: 13px; }
.user-row summary div > span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.role { background: #eef1ef; color: #59645d; }
.edit-label { color: var(--lime-dark); font-size: 11px; font-weight: 800; }
.user-edit { padding: 18px; background: #fafcf9; border-top: 1px solid var(--line); }
.text-danger { margin-top: 15px; padding: 0; background: transparent; border: 0; color: var(--danger); font-size: 11px; font-weight: 750; }

.public-shell { width: min(1100px, calc(100% - 40px)); min-height: 100vh; margin: 0 auto; padding: 34px 0; }
.auth-page { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 1fr 430px; gap: 100px; align-items: center; }
.auth-copy { padding: 50px; background: var(--ink); border-radius: 22px; color: #fff; }
.auth-copy .eyebrow { margin-top: 45px; color: #9ba69d; }
.auth-copy h1 { margin: 15px 0 20px; font-size: clamp(50px, 6vw, 76px); line-height: .95; letter-spacing: -4px; }
.auth-copy > p:last-child { max-width: 480px; color: #aeb7b0; line-height: 1.65; }
.auth-card { padding: 35px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 25px 70px rgba(27,43,31,.1); }
.auth-card h2 { margin: 8px 0 28px; font-size: 32px; letter-spacing: -1.5px; }
.auth-card label:not(.check-row) { margin-top: 17px; }
.continue-page { min-height: calc(100vh - 68px); display: flex; flex-direction: column; }
.continue-card { width: min(560px, 100%); margin: auto; padding: 50px; background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 20px 60px rgba(32,46,36,.08); text-align: center; }
.continue-icon { display: grid; place-items: center; width: 55px; height: 55px; margin: 0 auto 25px; background: var(--lime); border-radius: 12px; font-size: 23px; }
.continue-card h1 { margin: 12px 0; font-size: 44px; letter-spacing: -2.4px; }
.destination { overflow-wrap: anywhere; margin: 0; color: var(--muted); line-height: 1.6; }
.continue-card .primary-button { margin-top: 28px; text-align: left; }
.safety-note { margin: 16px 0 0; color: #8d958f; font-size: 10px; }
.payment-gate { min-height: calc(100vh - 68px); display: grid; place-items: center; }
.secure-payment-button { display: inline-flex; align-items: center; gap: 11px; padding: 16px 24px; background: #fff; border: 2px solid #25a244; border-radius: 12px; box-shadow: 0 12px 35px rgba(37,162,68,.15); color: #172019; font-size: 16px; font-weight: 850; text-decoration: none; transition: transform .15s, box-shadow .15s, background .15s; }
.secure-payment-button svg { width: 22px; height: 22px; fill: #25a244; }
.secure-payment-button:hover { transform: translateY(-2px); background: #f3fff6; box-shadow: 0 16px 40px rgba(37,162,68,.22); }

@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; z-index: 20; left: -260px; width: 240px; transition: left .2s; box-shadow: 20px 0 60px rgba(0,0,0,.22); }
    .sidebar.open { left: 0; }
    .mobile-header { display: flex; align-items: center; gap: 16px; padding: 18px 24px; background: #fff; border-bottom: 1px solid var(--line); }
    .mobile-header button { background: transparent; border: 0; font-size: 20px; }
    .page-wrap { width: min(100% - 32px, 1380px); padding-top: 28px; }
    .user-form { grid-template-columns: 1fr 1fr; }
    .auth-page { grid-template-columns: 1fr; gap: 25px; padding: 25px 0; }
}

@media (max-width: 600px) {
    .page-header { align-items: flex-start; flex-direction: column; }
    .stats-grid, .form-grid, .user-form { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: span 1; }
    .panel { padding: 18px; }
    .dt-container .dt-search input { min-width: 0; width: 100%; }
    .user-row summary { grid-template-columns: 38px 1fr auto; }
    .user-row .role { display: none; }
    .public-shell { width: min(100% - 24px, 1100px); padding: 12px 0; }
    .auth-copy { padding: 32px 25px; }
    .auth-copy h1 { font-size: 48px; letter-spacing: -2.8px; }
    .auth-card, .continue-card { padding: 28px 22px; }
    .continue-card h1 { font-size: 36px; }
}
