:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #667085;
    --line: #d9e1ec;
    --brand: #0f766e;
    --brand-dark: #115e59;
    --danger: #dc2626;
    --warning: #b45309;
    --ok: #15803d;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    display: grid;
    grid-template-columns: 260px 1fr;
}

body.auth-page {
    align-items: center;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 34%),
        linear-gradient(315deg, rgba(225, 29, 72, 0.12), transparent 32%),
        #f4f8fb;
    display: flex;
    justify-content: center;
    padding: 24px;
}

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

img,
svg {
    max-width: 100%;
}

.sidebar {
    background: #111827;
    color: #eef2ff;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 22px 18px;
    position: sticky;
    top: 0;
}

.brand {
    align-items: center;
    display: flex;
    gap: 12px;
    margin-bottom: 28px;
}

.brand-mark {
    align-items: center;
    background: var(--brand);
    border-radius: 8px;
    display: inline-flex;
    font-weight: 800;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.brand small {
    color: #a7b0c2;
    display: block;
    font-size: 12px;
    margin-top: 3px;
}

nav {
    display: grid;
    gap: 6px;
}

nav a {
    border-radius: 8px;
    color: #cbd5e1;
    min-height: 40px;
    padding: 11px 12px;
}

nav a:hover {
    background: #1f2937;
    color: #fff;
}

.sidebar-user {
    background: #172033;
    border: 1px solid #263244;
    border-radius: 8px;
    display: grid;
    gap: 12px;
    margin-top: auto;
    padding: 12px;
}

.sidebar-user-card {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: 38px minmax(0, 1fr);
}

.sidebar-user-avatar {
    align-items: center;
    background: #0f766e;
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    font-weight: 900;
    height: 38px;
    justify-content: center;
    width: 38px;
}

.sidebar-user small {
    color: #a7b0c2;
    display: block;
    font-size: 11px;
    margin-bottom: 3px;
}

.sidebar-user strong {
    color: #fff;
    display: block;
    font-size: 13px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.logout-button {
    align-items: center;
    background: #fff1f2;
    border-radius: 7px;
    color: #be123c;
    display: flex;
    font-size: 13px;
    font-weight: 800;
    justify-content: center;
    min-height: 38px;
    padding: 9px 12px;
}

.logout-button:hover {
    background: #e11d48;
    color: #fff;
}

.main {
    min-width: 0;
    padding: 28px;
}

.auth-shell {
    background: #ffffff;
    border: 1px solid rgba(217, 225, 236, 0.9);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.16);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    min-height: 560px;
    overflow: hidden;
    width: min(100%, 980px);
}

.auth-showcase {
    background:
        linear-gradient(145deg, rgba(17, 24, 39, 0.94), rgba(15, 118, 110, 0.9)),
        #111827;
    color: #fff;
    display: grid;
    min-height: 100%;
    padding: 34px;
    position: relative;
}

.auth-showcase::after {
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.16) 1px, transparent 1px),
        linear-gradient(180deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
    background-size: 46px 46px;
    content: "";
    inset: 0;
    opacity: 0.24;
    position: absolute;
}

.auth-showcase > * {
    position: relative;
    z-index: 1;
}

.auth-logo {
    align-items: center;
    background: #ffffff;
    border-radius: 8px;
    color: var(--brand);
    display: inline-flex;
    font-size: 24px;
    font-weight: 900;
    height: 54px;
    justify-content: center;
    width: 54px;
}

.auth-kicker {
    color: #99f6e4;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0 0 12px;
    text-transform: uppercase;
}

.auth-showcase h1 {
    font-size: 48px;
    line-height: 1.02;
    margin: 0;
    max-width: 360px;
}

.auth-owner {
    color: #d7fff7;
    font-weight: 800;
    margin: 16px 0 0;
}

.auth-metrics {
    align-self: end;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.auth-metrics span {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    color: #ecfeff;
    font-size: 13px;
    font-weight: 800;
    padding: 10px 12px;
}

.auth-panel {
    align-content: center;
    background: var(--panel);
    display: grid;
    padding: 42px;
}

.auth-heading {
    align-items: center;
    display: flex;
    gap: 14px;
    margin-bottom: 28px;
}

.auth-heading h2 {
    font-size: 28px;
    line-height: 1.1;
    margin: 0;
}

.auth-heading p {
    color: var(--muted);
    margin: 5px 0 0;
}

.auth-form {
    display: grid;
    gap: 18px;
}

.auth-form label {
    color: #1f2937;
    font-size: 14px;
    font-weight: 800;
}

.auth-form input {
    background: #f8fafc;
    border-color: #d7e0eb;
    min-height: 48px;
}

.auth-form input:focus {
    background: #fff;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.13);
    outline: none;
}

.auth-form button {
    font-size: 16px;
    min-height: 50px;
    margin-top: 4px;
}

.page-head {
    align-items: start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 22px;
}

.page-head > * {
    min-width: 0;
}

h1, h2, h3 {
    font-weight: 900;
    margin: 0;
}

.page-head h1,
.panel-head h2,
.auth-heading h2 {
    color: var(--ink);
    font-weight: 900;
}

.page-head p,
.muted {
    color: var(--muted);
}

.page-head p {
    margin: 7px 0 0;
}

.dashboard-owner {
    color: #2563eb;
    font-size: 14px;
    font-weight: 900;
    margin-bottom: 6px;
    text-transform: uppercase;
}

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

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

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

.stat {
    padding: 18px;
}

.stat strong {
    display: block;
    font-size: 28px;
    font-weight: 900;
    margin-top: 8px;
}

.stat span {
    font-weight: 800;
}

.panel {
    margin-bottom: 18px;
    padding: 18px;
}

.panel-head {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 14px;
}

.panel-head > * {
    min-width: 0;
}

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

.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.five {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

form.grid {
    align-items: end;
}

label {
    color: #344054;
    display: grid;
    font-size: 13px;
    font-weight: 800;
    gap: 7px;
}

input,
select,
textarea {
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    color: var(--ink);
    font: inherit;
    min-height: 40px;
    padding: 9px 10px;
    width: 100%;
}

input:disabled,
select:disabled,
textarea:disabled {
    opacity: 1;
}

textarea {
    min-height: 84px;
    resize: vertical;
}

select[multiple] {
    min-height: 126px;
}

.sale-items {
    display: grid;
    gap: 12px;
    grid-column: 1 / -1;
}

.sale-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 12px;
}

.sale-item.is-hidden,
.is-hidden {
    display: none;
}

.summary-panel {
    align-items: center;
    background: #eef6f5;
    border: 1px solid #c7dedb;
    border-radius: 8px;
    display: flex;
    gap: 16px;
    grid-column: 1 / -1;
    justify-content: flex-end;
    padding: 12px;
}

.detail-list {
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 8px;
    display: grid;
    gap: 10px;
    padding: 12px;
}

.detail-item {
    background: #ccfbf1;
    border: 1px solid #14b8a6;
    border-left: 8px solid #0f766e;
    box-shadow: 0 1px 0 rgba(15, 118, 110, 0.18);
    border-radius: 8px;
    display: grid;
    gap: 4px;
    grid-template-columns: 1.1fr 0.8fr 1.7fr 1fr 0.7fr auto;
    padding: 12px;
}

.selectable-detail-item {
    grid-template-columns: auto 1.1fr 0.8fr 1.7fr 1fr 0.7fr auto;
}

.renew-check {
    align-items: center;
    display: inline-flex;
    justify-content: center;
}

.renew-check input {
    accent-color: var(--brand);
    cursor: pointer;
    height: 18px;
    min-height: 18px;
    padding: 0;
    width: 18px;
}

.renew-selected-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.detail-item > *,
.line-secret > *,
.modal-row > *,
td,
th {
    min-width: 0;
}

.detail-item strong {
    color: var(--brand-dark);
}

.platform-chip {
    align-items: center;
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    min-height: 24px;
    padding: 6px 10px;
    width: fit-content;
}

.platform-chip-netflix,
.platform-chip-youtube {
    background: #e50914;
}

.platform-chip-disney,
.platform-chip-prime {
    background: #0ea5e9;
}

.platform-chip-spotify {
    background: #16a34a;
}

.platform-chip-max {
    background: #6d28d9;
}

.platform-chip-crunchyroll {
    background: #f97316;
}

.platform-chip-iptv {
    background: #0f766e;
}

.platform-chip-default {
    background: #475569;
}

.text-link {
    background: transparent;
    border: 0;
    color: var(--brand);
    cursor: pointer;
    display: inline;
    font: inherit;
    font-weight: 800;
    min-height: 0;
    padding: 0;
    text-align: left;
    text-decoration: underline;
}

.text-link:hover {
    background: transparent;
    color: var(--brand-dark);
}

.line-secret {
    background: #ffedd5;
    border: 1px solid #fb923c;
    border-left: 7px solid #ea580c;
    border-radius: 8px;
    display: grid;
    gap: 6px 14px;
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 8px;
    padding: 10px;
}

.line-secret.is-hidden {
    display: none;
}

.modal {
    align-items: center;
    background: rgba(15, 23, 42, 0.45);
    bottom: 0;
    display: flex;
    justify-content: center;
    left: 0;
    padding: 24px;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 20;
}

.modal.is-hidden {
    display: none;
}

.modal-box {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    max-width: 760px;
    padding: 16px;
    width: min(100%, 760px);
    max-height: calc(100vh - 48px);
    overflow: auto;
}

.modal-head {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 8px;
}

.modal-list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.modal-row {
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 10px;
}

button,
.button {
    background: var(--brand);
    border: 0;
    border-radius: 7px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    justify-content: center;
    min-height: 40px;
    padding: 10px 14px;
    text-align: center;
}

button:hover,
.button:hover {
    background: var(--brand-dark);
}

button.danger,
.button.danger {
    background: var(--danger);
}

button.danger:hover,
.button.danger:hover {
    background: #b91c1c;
}

.button.secondary {
    background: #e2e8f0;
    color: #1f2937;
}

button.text-link,
button.text-link:hover {
    background: transparent;
    border: 0;
    color: var(--brand);
    display: inline;
    font: inherit;
    font-weight: 800;
    justify-content: flex-start;
    min-height: 0;
    padding: 0;
    text-align: left;
    text-decoration: underline;
}

button.text-link:hover {
    color: var(--brand-dark);
}

.copyable {
    align-items: center;
    display: inline-flex;
    gap: 6px;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.copy-button {
    align-items: center;
    background: #e2e8f0;
    border: 0;
    border-radius: 6px;
    color: #1f2937;
    cursor: pointer;
    display: inline-flex;
    font-size: 12px;
    height: 26px;
    justify-content: center;
    min-height: 26px;
    padding: 0;
    width: 30px;
}

.copy-button:hover,
.copy-button.is-copied {
    background: var(--brand);
    color: #fff;
}

.input-copy {
    align-items: center;
    display: grid;
    gap: 6px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    border-collapse: collapse;
    min-width: 760px;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.history-row.history-row-a > td {
    background: #f8fbff;
}

.history-row.history-row-b > td {
    background: #eef7ff;
}

.history-row:hover > td {
    background: #e1f0ff;
}

.sale-detail-row.history-row-a > td {
    background: #f8fbff;
}

.sale-detail-row.history-row-b > td {
    background: #eef7ff;
}

.badge {
    background: #e2e8f0;
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 9px;
}

.badge.ok {
    background: #dcfce7;
    color: var(--ok);
}

.badge.warn {
    background: #fef3c7;
    color: var(--warning);
}

.badge.danger {
    background: #fee2e2;
    color: var(--danger);
}

.platform-dot {
    border-radius: 50%;
    display: inline-block;
    height: 10px;
    margin-right: 7px;
    width: 10px;
}

.flash {
    border-radius: 8px;
    margin-bottom: 18px;
    padding: 12px 14px;
}

.flash.success {
    background: #dcfce7;
    color: #14532d;
}

.flash.error {
    background: #fee2e2;
    color: #7f1d1d;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.actions form {
    margin: 0;
}

.actions.stack {
    align-items: stretch;
    flex-direction: column;
    min-width: 92px;
}

.actions.icons {
    align-items: center;
    gap: 6px;
}

.button.small,
button.small {
    font-size: 12px;
    min-height: 32px;
    padding: 7px 9px;
}

.icon-button {
    align-items: center;
    aspect-ratio: 1;
    font-size: 16px;
    line-height: 1;
    min-height: 34px;
    padding: 0;
    width: 34px;
}

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

@media (max-width: 1180px) {
    body {
        grid-template-columns: 224px 1fr;
    }

    .main {
        padding: 22px;
    }

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

    .three,
    .sale-item {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .selectable-detail-item {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .line-secret,
    .modal-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    body {
        display: block;
    }

    body.auth-page {
        display: flex;
        padding: 16px;
    }

    .auth-shell {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .auth-showcase {
        min-height: 260px;
        padding: 26px;
    }

    .auth-showcase h1 {
        font-size: 36px;
    }

    .auth-panel {
        padding: 28px;
    }

    .sidebar {
        display: grid;
        gap: 14px;
        min-height: auto;
        padding: 14px 16px;
        position: static;
    }

    .brand {
        margin-bottom: 0;
    }

    .sidebar-user {
        margin-top: 0;
    }

    nav {
        display: flex;
        gap: 8px;
        margin-inline: -16px;
        overflow-x: auto;
        padding: 0 16px 4px;
        scrollbar-width: thin;
    }

    nav a {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .main {
        padding: 18px;
    }

    .stats,
    .two,
    .three,
    .five,
    .sale-item,
    .detail-item,
    .line-secret,
    .modal-row {
        grid-template-columns: 1fr;
    }

    .selectable-detail-item {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .summary-panel {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-head {
        display: grid;
    }

    .page-head .actions,
    .panel-head .actions {
        width: 100%;
    }

    .page-head .button,
    .panel-head .button {
        flex: 1 1 160px;
    }

    .panel-head {
        align-items: start;
        display: grid;
    }
}

@media (max-width: 640px) {
    body.auth-page {
        padding: 10px;
    }

    .auth-showcase {
        min-height: auto;
        padding: 20px;
    }

    .auth-showcase h1 {
        font-size: 30px;
        max-width: none;
    }

    .auth-metrics {
        margin-top: 24px;
    }

    .auth-panel {
        padding: 22px 18px;
    }

    .auth-heading {
        align-items: flex-start;
        gap: 10px;
    }

    .auth-heading h2 {
        font-size: 24px;
    }

    .main {
        padding: 14px;
    }

    h1 {
        font-size: 25px;
        line-height: 1.15;
    }

    h2 {
        font-size: 20px;
        line-height: 1.2;
    }

    .panel,
    .stat {
        padding: 14px;
    }

    .stat strong {
        font-size: 24px;
    }

    .sidebar-user {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .logout-button {
        min-width: 112px;
    }

    .actions {
        width: 100%;
    }

    .actions:not(.icons) > .button,
    .actions:not(.icons) > button {
        flex: 1 1 100%;
    }

    form.grid > button,
    form.grid > .button {
        width: 100%;
    }

    .summary-panel {
        width: 100%;
    }

    .summary-panel button {
        width: 100%;
    }

    .copyable {
        align-items: flex-start;
    }

    .table-wrap {
        margin-inline: -14px;
        padding-inline: 14px;
    }

    th,
    td {
        padding: 10px 8px;
    }

    .detail-item {
        border-left-width: 5px;
    }

    .line-secret {
        gap: 8px;
    }

    .modal {
        align-items: stretch;
        padding: 10px;
    }

    .modal-box {
        max-height: calc(100vh - 20px);
        padding: 14px;
    }

    .modal-head {
        align-items: flex-start;
    }
}

@media (max-width: 420px) {
    .brand-mark {
        height: 38px;
        width: 38px;
    }

    .brand strong {
        font-size: 15px;
    }

    .brand small {
        font-size: 11px;
    }

    .sidebar-user {
        grid-template-columns: 1fr;
    }

    .logout-button {
        width: 100%;
    }

    .auth-metrics span {
        width: 100%;
    }

    .actions:not(.icons) .button,
    .actions:not(.icons) button {
        width: 100%;
    }

    .actions.icons,
    .actions.icons .button,
    .actions.icons button {
        width: auto;
    }

    .actions.icons {
        justify-content: flex-start;
    }

    table {
        min-width: 680px;
    }
}
