:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-soft: #eef6f4;
    --text: #17212b;
    --muted: #657184;
    --line: #dfe5ec;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #2563eb;
    --warning: #b7791f;
    --warning-bg: #fff7df;
    --danger: #b42318;
    --danger-bg: #fff1f0;
    --success: #15803d;
    --success-bg: #ecfdf3;
    --shadow: 0 18px 45px rgba(23, 33, 43, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

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

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

textarea {
    resize: vertical;
}

button {
    border: 0;
    cursor: pointer;
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px;
    background: #111827;
    color: #f8fafc;
}

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

.brand-mark {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: var(--radius);
    background: #14b8a6;
    color: #062a27;
    font-weight: 800;
}

.brand-mark.large {
    width: 58px;
    height: 58px;
    margin-bottom: 20px;
    font-size: 20px;
}

.brand strong,
.brand small {
    display: block;
}

.brand small,
.sidebar-note span {
    color: #cbd5e1;
    font-size: 12px;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav a {
    display: block;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: #dbe4ef;
}

.nav a:hover,
.nav a.active {
    background: #223044;
    color: #ffffff;
}

.sidebar-note {
    margin-top: auto;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.04);
}

.sidebar-note strong,
.sidebar-note span {
    display: block;
    overflow-wrap: anywhere;
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.topbar h1,
.login-copy h1,
.project-hero h2 {
    margin: 0;
    font-size: clamp(26px, 3vw, 36px);
    line-height: 1.15;
}

.topbar-user,
.toolbar-actions,
.hero-actions,
.badges {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.btn {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    white-space: nowrap;
}

.btn:hover {
    border-color: #b9c3d1;
}

.btn.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
}

.btn.primary:hover {
    background: var(--primary-dark);
}

.btn.ghost {
    background: transparent;
}

.btn.small {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 13px;
}

.icon {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.btn.wide {
    width: 100%;
}

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

.alert.success {
    border-color: #bbf7d0;
    background: var(--success-bg);
    color: var(--success);
}

.alert.danger {
    border-color: #fecaca;
    background: var(--danger-bg);
    color: var(--danger);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        linear-gradient(120deg, rgba(20, 184, 166, 0.14), rgba(37, 99, 235, 0.1)),
        #f7fafc;
}

.login-panel {
    width: min(1060px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    gap: 28px;
    align-items: stretch;
}

.login-copy,
.login-form {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.login-copy {
    padding: 48px;
}

.login-copy p {
    max-width: 680px;
    color: var(--muted);
}

.demo-logins {
    display: grid;
    gap: 8px;
    margin-top: 32px;
    color: var(--muted);
    font-size: 14px;
}

.login-form {
    display: grid;
    align-content: center;
    gap: 18px;
    padding: 34px;
}

.login-form h2,
.toolbar h2,
.panel h2,
.form-head h2 {
    margin: 0;
    font-size: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

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

.stat-card {
    padding: 18px;
}

.stat-card span,
.money-stack span,
.link-list span,
.detail-grid dt,
.muted {
    color: var(--muted);
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: clamp(22px, 2.4vw, 30px);
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.stat-card.accent {
    border-color: #bfdbfe;
    background: #eff6ff;
}

.stat-card.warn {
    border-color: #fde68a;
    background: var(--warning-bg);
}

.stat-card.success {
    border-color: #bbf7d0;
    background: var(--success-bg);
}

.stat-card.danger {
    border-color: #fecaca;
    background: var(--danger-bg);
}

.toolbar,
.project-hero,
.form-head,
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.toolbar,
.project-hero {
    margin-bottom: 18px;
    padding: 18px;
}

.toolbar p,
.form-head p,
.project-hero p {
    margin: 4px 0 0;
    color: var(--muted);
}

.content-grid {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
}

.content-grid.two {
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
}

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

.panel-head {
    margin-bottom: 16px;
}

.panel-head a {
    color: var(--primary);
    font-weight: 800;
}

.panel-head span {
    color: var(--muted);
    font-size: 13px;
}

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

.bulk-action-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfdff;
    color: var(--muted);
}

.bulk-action-bar.is-active {
    border-color: #99f6e4;
    background: #f0fdfa;
    color: var(--text);
}

.bulk-action-bar button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.bulk-action-bar [data-bulk-submit] {
    display: none;
}

.bulk-action-bar.is-active [data-bulk-submit] {
    display: inline-flex;
}

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

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

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

th:last-child,
td.actions {
    width: 214px;
    white-space: nowrap;
}

td.actions {
    text-align: right;
    vertical-align: middle;
}

.select-cell {
    width: 46px;
    text-align: center;
    vertical-align: middle;
}

.select-cell input[type="checkbox"] {
    width: 18px;
    min-height: 18px;
    padding: 0;
}

.icon-actions > a,
.icon-actions > button,
.icon-actions > form {
    margin-left: 6px;
    vertical-align: middle;
}

.inline-delete-form {
    display: inline-flex;
}

.icon-button {
    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    color: #475569;
}

.icon-button:hover,
.icon-button.is-active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--surface-soft);
}

.icon-button.danger:hover {
    border-color: #fecaca;
    background: var(--danger-bg);
    color: var(--danger);
}

.info-cell {
    width: 210px;
}

.info-cell strong,
.info-cell span,
.money-cell strong,
.money-cell span,
.ticket-cell strong,
.ticket-cell span {
    display: block;
}

.info-cell strong {
    font-size: 14px;
}

.info-cell span,
.money-cell span,
.ticket-cell span {
    color: var(--muted);
    font-size: 13px;
}

.project-cell {
    min-width: 320px;
}

.project-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 7px;
}

.project-links a,
.project-links span {
    display: inline-flex;
    min-height: 26px;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f8fafc;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.project-links a {
    color: var(--accent);
}

.money-cell,
.ticket-cell {
    white-space: nowrap;
}

.quick-edit-row.is-hidden,
.tech-info-row.is-hidden,
.ticket-info-row.is-hidden,
.upgrade-info-row.is-hidden,
.upgrade-detail-body.is-hidden {
    display: none;
}

.quick-edit-row td,
.tech-info-row td,
.ticket-info-row td,
.upgrade-info-row td {
    padding: 0 12px 16px;
    background: #f8fafc;
}

.quick-edit-form,
.tech-info-form,
.ticket-quick-form,
.ticket-quick-history,
.upgrade-quick-form,
.upgrade-quick-history {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.quick-edit-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

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

.tech-info-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.ticket-quick-grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.15fr);
    gap: 14px;
}

.upgrade-quick-grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
    gap: 14px;
}

.compact-list {
    max-height: 360px;
    overflow: auto;
}

.compact-ticket p {
    max-height: 72px;
    overflow: auto;
}

tbody tr:hover {
    background: #f8fafc;
}

.link-strong {
    color: var(--primary-dark);
    font-weight: 800;
}

.line-clamp {
    display: block;
    max-width: 360px;
    margin-top: 4px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge {
    display: inline-flex;
    min-height: 26px;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    background: #eef2f7;
    color: #475569;
    font-size: 12px;
    font-weight: 800;
    width: 100px;
}

.badge.success {
    background: var(--success-bg);
    color: var(--success);
}

.badge.warning {
    background: var(--warning-bg);
    color: var(--warning);
}

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

.inline-status-form {
    display: inline-flex;
}

.inline-status-select {
    width: auto;
    min-height: 28px;
    padding: 4px 24px 4px 10px;
    border: 0;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.inline-status-select:focus {
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.empty-state {
    display: grid;
    gap: 4px;
    padding: 28px;
    border: 1px dashed #cbd5e1;
    border-radius: var(--radius);
    background: #fbfdff;
    color: var(--muted);
    text-align: center;
}

.empty-state.compact {
    padding: 18px;
}

.customer-strip {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

.customer-strip a {
    display: grid;
    gap: 4px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfdff;
}

.customer-strip span {
    color: var(--muted);
    font-size: 13px;
}

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

.form-grid,
.filters,
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.filters {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-items: end;
}

.project-filter-box {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px 14px;
    margin-bottom: 14px;
    padding: 16px 18px;
}

.filter-head {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 2px;
}

.filter-head h2 {
    margin: 0;
    font-size: 20px;
}

.filter-head p {
    margin: 3px 0 0;
    color: var(--muted);
}

.project-filter-box label {
    gap: 5px;
}

.project-filter-box input,
.project-filter-box select {
    min-height: 38px;
    padding: 8px 10px;
}

.project-filter-box .filter-actions {
    align-self: end;
}

.span-2 {
    grid-column: span 2;
}

.field-hidden {
    display: none !important;
}

.mailer-options,
.settings-actions {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.mailer-panel {
    border-top: 3px solid #0ea5e9;
}

.radio-row {
    display: inline-flex;
    width: auto;
    min-height: 34px;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-weight: 500;
}

.radio-row input[type="radio"] {
    width: 16px;
    min-height: 16px;
}

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

.hosting-fields {
    display: grid;
    gap: 12px;
    padding: 12px;
    border: 1px dashed #cbd5e1;
    border-radius: var(--radius);
    background: #fbfdff;
}

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

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 700;
}

.check-row {
    display: flex;
    min-height: 42px;
    align-items: center;
    gap: 8px;
    align-self: end;
}

.check-row input[type="checkbox"] {
    width: 18px;
    min-height: 18px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--text);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.filter-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.detail-grid {
    margin: 0;
}

.detail-grid div {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfdff;
}

.detail-grid dt {
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.detail-grid dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.money-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.money-stack div,
.link-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfdff;
}

.money-stack strong,
.link-list a,
.link-list em {
    overflow-wrap: anywhere;
    text-align: right;
}

.link-list {
    display: grid;
    gap: 10px;
}

.link-list a {
    color: var(--accent);
    font-weight: 700;
}

.secret-block {
    min-height: 110px;
    margin: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #0f172a;
    color: #e2e8f0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.ticket-list {
    display: grid;
    gap: 10px;
}

.upgrade-list {
    display: grid;
    gap: 10px;
}

.upgrade-list.is-hidden {
    display: none;
}

.ticket-row,
.ticket-card,
.upgrade-card {
    display: grid;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfdff;
}

.ticket-row small,
.ticket-card small {
    color: var(--muted);
}

.ticket-card p {
    margin: 8px 0 0;
    color: #334155;
}

.ticket-card-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.upgrade-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.upgrade-card p {
    margin: 4px 0 0;
    color: #334155;
}

.ticket-card-head > div {
    display: grid;
    gap: 5px;
}

.compact-form {
    align-content: start;
}

.history-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(15, 23, 42, 0.42);
}

.history-drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 80;
    width: min(520px, calc(100vw - 22px));
    height: 100vh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    border-left: 1px solid var(--line);
    background: #f3f5f9;
    box-shadow: -24px 0 50px rgba(15, 23, 42, 0.18);
    transform: translateX(104%);
    transition: transform 220ms ease;
}

.history-drawer.is-open {
    transform: translateX(0);
}

.history-drawer-head {
    display: flex;
    min-height: 54px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: #ffffff;
}

.history-drawer-head h2 {
    margin: 0;
    font-size: 18px;
}

.history-close {
    display: inline-grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: var(--radius);
    background: transparent;
    color: #475569;
    font-size: 24px;
    line-height: 1;
}

.history-close:hover {
    background: #eef2f7;
    color: var(--text);
}

.history-drawer-body {
    min-height: 0;
    overflow: auto;
    padding: 18px 16px 28px;
}

.history-project-summary {
    display: grid;
    gap: 4px;
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.history-project-summary span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.history-project-summary strong {
    overflow-wrap: anywhere;
}

.history-list {
    display: grid;
    gap: 12px;
}

.history-card {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.history-card-top {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.history-card-top div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.history-card-top span {
    color: var(--muted);
    font-size: 12px;
}

.history-card-top strong {
    max-width: 65%;
    color: #0f172a;
    font-size: 13px;
    text-align: right;
    overflow-wrap: anywhere;
}

.history-changes {
    display: grid;
    gap: 6px;
    padding: 8px;
    border: 1px solid #fed7aa;
    border-radius: var(--radius);
    background: #fffaf3;
}

.history-no-changes {
    padding: 8px;
    border: 1px dashed #cbd5e1;
    border-radius: var(--radius);
    background: #f8fafc;
    color: var(--muted);
    font-size: 13px;
}

.history-change-row {
    display: grid;
    gap: 3px;
}

.history-change-row span {
    color: #9a3412;
    font-size: 12px;
}

.history-change-row p {
    display: grid;
    gap: 3px;
    margin: 0;
    color: #9a3412;
    font-size: 13px;
}

.history-change-row del,
.history-change-row ins {
    overflow-wrap: anywhere;
}

.history-change-row del {
    color: #94a3b8;
}

.history-change-row ins {
    color: #c2410c;
    text-decoration: none;
}

@media (max-width: 1100px) {
    .stats-grid,
    .customer-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .content-grid.two,
    .login-panel {
        grid-template-columns: 1fr;
    }

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

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

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

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

    .tech-info-grid {
        grid-template-columns: 1fr;
    }

    .ticket-quick-grid {
        grid-template-columns: 1fr;
    }

    .upgrade-quick-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        padding: 16px;
    }

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

    .main {
        padding: 18px;
    }

    .topbar,
    .toolbar,
    .project-hero,
    .form-head,
    .filter-head,
    .panel-head,
    .ticket-card-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .form-grid,
    .filters,
    .project-filter-box,
    .detail-grid,
    .quick-edit-grid,
    .mailer-grid,
    .hosting-config,
    .tech-info-grid,
    .ticket-quick-grid,
    .upgrade-quick-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }

    .login-copy,
    .login-form {
        padding: 24px;
    }

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