* { box-sizing: border-box; }

:root {
    --ink: #111827;
    --soft-ink: #374151;
    --muted: #6b7280;
    --line: #d9e1ea;
    --line-strong: #c6d0dc;
    --panel: #ffffff;
    --page: #f5f7fb;
    --black: #101214;
    --emerald: #047857;
    --emerald-soft: #dff7ec;
    --indigo: #4f46e5;
    --indigo-soft: #e7e9ff;
    --amber: #b7791f;
    --amber-soft: #fff2cf;
    --red: #b42318;
    --red-soft: #fee4e2;
    --focus: rgba(79, 70, 229, .18);
    --shadow: 0 18px 50px rgba(17, 24, 39, .07);
}

html { min-height: 100%; }

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

a {
    color: var(--indigo);
    text-decoration: none;
}

a:hover { text-decoration: none; }

code {
    display: inline-block;
    max-width: 100%;
    padding: 2px 6px;
    overflow-wrap: anywhere;
    color: #3730a3;
    background: #f1f3ff;
    border: 1px solid #dfe3ff;
    border-radius: 5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: .88em;
}

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

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    height: 100vh;
    min-width: 0;
    flex-direction: column;
    gap: 22px;
    padding: 18px;
    background: var(--panel);
    border-right: 1px solid var(--line);
}

.brand,
.auth-brand {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 11px;
    color: var(--ink);
}

.brand:hover,
.auth-brand:hover { color: var(--ink); }

.brand-mark {
    display: inline-flex;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--black);
    border-radius: 8px;
    box-shadow: inset 0 -3px 0 var(--emerald);
    font-weight: 800;
    letter-spacing: 0;
}

.brand strong,
.auth-brand strong {
    display: block;
    color: var(--ink);
    font-size: .98rem;
    line-height: 1.1;
}

.brand small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: .78rem;
}

.side-nav {
    display: grid;
    gap: 6px;
}

.side-nav__link {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 11px;
    min-height: 42px;
    padding: 10px 11px;
    color: var(--soft-ink);
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: 0;
}

.side-nav__link:hover { background: #f3f6fa; }

.side-nav__link.is-active {
    color: #fff;
    background: var(--black);
}

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

.sidebar-user {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 36px;
    gap: 10px;
    align-items: center;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.avatar {
    display: inline-flex;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    color: #064e3b;
    background: var(--emerald-soft);
    border: 1px solid #bdebd6;
    border-radius: 8px;
    font-weight: 800;
}

.user-copy {
    min-width: 0;
}

.user-copy strong,
.user-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-copy strong { font-size: .9rem; }
.user-copy small { color: var(--muted); font-size: .78rem; }

.icon-button {
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    color: var(--soft-ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
}

.icon-button:hover { color: var(--red); border-color: #f4b8b3; background: #fff7f6; }

.app-main {
    min-width: 0;
}

.commandbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 28px;
    background: rgba(245, 247, 251, .9);
    border-bottom: 1px solid rgba(217, 225, 234, .78);
    backdrop-filter: blur(16px);
}

.commandbar strong {
    display: block;
    margin-top: 1px;
    font-size: 1.08rem;
}

.command-actions,
.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
}

.shell {
    width: min(1240px, calc(100% - 44px));
    margin: 28px auto 72px;
}

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

.page-head h1 {
    margin: 3px 0 0;
    color: var(--ink);
    font-size: clamp(1.55rem, 2vw, 2rem);
    line-height: 1.16;
    letter-spacing: 0;
}

.page-head p {
    max-width: 680px;
    margin: 8px 0 0;
    color: var(--muted);
}

.eyebrow {
    color: var(--muted);
    font-size: .75rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

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

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

.metric {
    min-width: 0;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 4px solid var(--line-strong);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.metric strong {
    display: block;
    margin-top: 5px;
    overflow-wrap: anywhere;
    font-size: 1.65rem;
    line-height: 1.08;
}

.metric--green { border-left-color: var(--emerald); }
.metric--indigo { border-left-color: var(--indigo); }
.metric--amber { border-left-color: var(--amber); }

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
    gap: 18px;
    align-items: start;
}

.readiness-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    margin-bottom: 18px;
}

.data-panel,
.form-panel,
.empty-panel {
    min-width: 0;
    margin-bottom: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.form-panel { padding: 20px; }

.empty-panel {
    padding: 24px;
    color: var(--muted);
}

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

.form-panel .panel-head {
    margin: -20px -20px 18px;
}

.panel-head h2 {
    margin: 0;
    color: var(--ink);
    font-size: .98rem;
    line-height: 1.25;
    letter-spacing: 0;
}

.panel-count,
.text-link {
    color: var(--muted);
    font-size: .82rem;
    font-weight: 800;
}

.text-link { color: var(--indigo); }

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

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    color: var(--muted);
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
    white-space: nowrap;
}

td {
    color: var(--soft-ink);
    font-size: .93rem;
}

td strong {
    display: block;
    color: var(--ink);
}

td small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
}

tr:last-child td { border-bottom: 0; }

.row-actions {
    width: 1%;
    white-space: nowrap;
}

.row-actions__group {
    display: inline-flex;
    gap: 7px;
    align-items: center;
}

.row-actions form {
    margin: 0;
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 900;
    line-height: 1;
    text-transform: capitalize;
    white-space: nowrap;
}

.status--active { color: #065f46; background: var(--emerald-soft); }
.status--draft { color: #8a5b00; background: var(--amber-soft); }
.status--disabled { color: var(--red); background: var(--red-soft); }

.logo-count {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 4px 9px;
    color: #3730a3;
    background: var(--indigo-soft);
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 900;
    white-space: nowrap;
}

.button {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 13px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    font: inherit;
    font-size: .9rem;
    font-weight: 850;
    line-height: 1.1;
    cursor: pointer;
    white-space: nowrap;
}

.button:hover {
    background: #f8fafc;
    border-color: #aebccd;
}

.button--primary {
    color: #fff;
    background: var(--emerald);
    border-color: var(--emerald);
}

.button--primary:hover {
    color: #fff;
    background: #05664c;
    border-color: #05664c;
}

.button--danger {
    color: #fff;
    background: var(--red);
    border-color: var(--red);
}

.button--danger:hover {
    color: #fff;
    background: #9f1f17;
    border-color: #9f1f17;
}

.button--ghost {
    color: var(--soft-ink);
    background: rgba(255, 255, 255, .68);
}

.button--small {
    min-height: 32px;
    padding: 7px 10px;
    font-size: .82rem;
}

.form-stack {
    display: grid;
    gap: 15px;
}

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

.field {
    display: grid;
    min-width: 0;
    gap: 7px;
}

.field--wide { grid-column: 1 / -1; }

.field span {
    color: var(--soft-ink);
    font-size: .8rem;
    font-weight: 850;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    color: var(--ink);
    background: #fff;
    border: 1px solid #c9d3df;
    border-radius: 8px;
    font: inherit;
    letter-spacing: 0;
}

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

input:focus,
select:focus,
textarea:focus,
.button:focus-visible,
.icon-button:focus-visible,
.side-nav__link:focus-visible,
.section-tabs a:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 1px;
    border-color: var(--indigo);
}

.field--check {
    display: flex;
    min-height: 42px;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 0 0;
}

.field--check input {
    width: 18px;
    min-height: 18px;
}

.filter-panel {
    margin-bottom: 18px;
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(160px, 220px) auto;
    gap: 12px;
    align-items: end;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}

.notice {
    margin-bottom: 18px;
    padding: 12px 14px;
    color: var(--soft-ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.notice--success {
    color: #065f46;
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.notice--error {
    color: var(--red);
    background: #fff6f5;
    border-color: #fecaca;
}

.detail-list {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
}

.detail-list div {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 12px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--line);
}

.detail-list div:last-child { border-bottom: 0; }

.detail-list--boxed {
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.detail-list dt {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.detail-list dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--ink);
}

.site-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    margin-bottom: 14px;
    overflow: hidden;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.site-strip div {
    min-width: 0;
    padding: 14px;
    background: #fff;
}

.site-strip span {
    display: block;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 900;
    text-transform: uppercase;
}

.site-strip strong {
    display: block;
    margin-top: 3px;
    overflow-wrap: anywhere;
    color: var(--ink);
    font-size: .94rem;
}

.readiness-list {
    display: grid;
    gap: 10px;
    padding: 14px;
}

.readiness-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 4px 10px;
    align-items: center;
    min-width: 0;
    padding: 11px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-left: 4px solid var(--line-strong);
    border-radius: 8px;
}

.readiness-item--ok { border-left-color: var(--emerald); }
.readiness-item--warn { border-left-color: var(--amber); }
.readiness-item--error { border-left-color: var(--red); }

.readiness-item strong,
.readiness-item small {
    min-width: 0;
    overflow-wrap: anywhere;
}

.readiness-item small {
    grid-column: 2;
    color: var(--muted);
    font-size: .82rem;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    justify-content: flex-end;
    padding: 14px 16px;
    border-top: 1px solid var(--line);
}

.pagination a,
.pagination span {
    display: inline-flex;
    min-width: 34px;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    padding: 7px 10px;
    color: var(--soft-ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 850;
}

.pagination span {
    color: #fff;
    background: var(--black);
    border-color: var(--black);
}

.pagination .is-disabled {
    color: #9ca3af;
    pointer-events: none;
}

.section-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 18px;
    padding: 6px;
    overflow-x: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.section-tabs a {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    padding: 7px 11px;
    color: var(--soft-ink);
    border-radius: 7px;
    font-size: .82rem;
    font-weight: 850;
    white-space: nowrap;
}

.section-tabs a:hover { background: #f3f6fa; }

.section-tabs a.is-active {
    color: #fff;
    background: var(--black);
}

.sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 0 0;
    background: linear-gradient(180deg, rgba(245, 247, 251, 0), var(--page) 38%);
}

.inline-form,
.auth-secondary-action {
    margin-top: 12px;
}

.logo-directory {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.site-card {
    min-width: 0;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.site-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.site-card h2 {
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 1.02rem;
}

.site-card p {
    margin: 4px 0 14px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.logo-dots {
    display: flex;
    gap: 7px;
    margin-bottom: 16px;
}

.logo-dots span {
    width: 24px;
    height: 7px;
    background: #e5e7eb;
    border-radius: 999px;
}

.logo-dots span.is-filled { background: var(--emerald); }

.logo-manager {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
}

.logo-slot {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 18px;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.logo-preview {
    display: flex;
    width: 100%;
    min-height: 136px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: var(--muted);
    background:
        linear-gradient(45deg, #eef2f7 25%, transparent 25%),
        linear-gradient(-45deg, #eef2f7 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eef2f7 75%),
        linear-gradient(-45deg, transparent 75%, #eef2f7 75%);
    background-color: #fff;
    background-position: 0 0, 0 9px, 9px -9px, -9px 0;
    background-size: 18px 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.logo-preview img {
    display: block;
    max-width: 82%;
    max-height: 108px;
    object-fit: contain;
}

.logo-preview .icon {
    width: 38px;
    height: 38px;
}

.logo-slot__content {
    min-width: 0;
}

.logo-slot__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.logo-slot h2 {
    margin: 0;
    font-size: 1rem;
}

.logo-slot p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: .86rem;
}

.asset-state {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    padding: 4px 8px;
    color: #065f46;
    background: var(--emerald-soft);
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 900;
    white-space: nowrap;
}

.upload-field {
    display: flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    color: var(--soft-ink);
    background: #f8fafc;
    border: 1px dashed #aebccd;
    border-radius: 8px;
    font-size: .86rem;
    font-weight: 850;
    cursor: pointer;
}

.upload-field span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.upload-field input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.upload-field:hover {
    color: #3730a3;
    background: #f1f3ff;
    border-color: var(--indigo);
}

.logo-remove {
    padding-top: 0;
}

.auth-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 28px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .88), rgba(245, 247, 251, .96)),
        repeating-linear-gradient(90deg, #eef2f7 0, #eef2f7 1px, transparent 1px, transparent 48px);
}

.auth-panel {
    width: min(430px, 100%);
    padding: 28px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.auth-panel h1 {
    margin: 24px 0 18px;
    font-size: 1.75rem;
    letter-spacing: 0;
}

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

    .sidebar {
        position: sticky;
        z-index: 30;
        height: auto;
        gap: 14px;
        padding: 12px 16px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .side-nav {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .side-nav__link {
        flex: 0 0 auto;
    }

    .sidebar-user {
        display: none;
    }

    .commandbar {
        top: 83px;
    }
}

@media (max-width: 860px) {
    .shell {
        width: min(100% - 28px, 1240px);
        margin-top: 20px;
    }

    .commandbar,
    .page-head,
    .logo-slot__head {
        align-items: flex-start;
        flex-direction: column;
    }

    .command-actions,
    .page-actions {
        justify-content: flex-start;
    }

    .metric-grid,
    .metric-grid--three,
    .dashboard-grid,
    .site-strip,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .field--wide {
        grid-column: auto;
    }

    table {
        min-width: 860px;
    }

    .logo-slot {
        grid-template-columns: 1fr;
    }

    .logo-preview {
        min-height: 120px;
    }
}

@media (max-width: 560px) {
    body {
        font-size: 14px;
    }

    .brand small,
    .commandbar .eyebrow {
        display: none;
    }

    .commandbar {
        top: 75px;
        padding: 12px 14px;
    }

    .side-nav__link {
        width: 42px;
        justify-content: center;
        padding: 10px;
    }

    .side-nav__link span {
        display: none;
    }

    .button {
        width: 100%;
        white-space: normal;
    }

    .command-actions,
    .page-actions,
    .sticky-actions {
        width: 100%;
    }

    .detail-list div {
        grid-template-columns: 1fr;
        gap: 3px;
    }
}
