/* Article overview: image and copy each get their own clear area. */
.article-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 350px), 1fr));
    gap: 20px;
}

.article-card {
    display: flex;
    min-width: 0;
    height: 100%;
    flex-direction: column;
    border-radius: 18px;
}

.article-card-link {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
}

.article-thumb {
    position: relative;
    height: auto;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: linear-gradient(145deg, #dce8df, #eef2e8);
}

.article-thumb img {
    position: absolute;
    inset: 0;
}

.article-thumb span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.article-thumb span b {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 10px;
    background: var(--green);
    color: #fff;
    letter-spacing: 0;
}

.article-card-link > div.article-card-body {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    padding: 20px;
}

.article-send-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 12px 17px 16px;
    border-top: 1px solid var(--line);
    background: #f8faf6;
}

.article-send-form select,
.article-send-form .button {
    min-height: 40px;
    padding-block: 8px;
}

.detail-actions {
    display: grid;
    width: min(100%, 330px);
    flex: none;
    gap: 10px;
}

.detail-actions form {
    display: grid;
    gap: 8px;
}

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

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

.inline-send .button {
    min-height: 36px;
    padding: 7px 10px;
    white-space: nowrap;
}

.article-card-top,
.article-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.article-card-top time {
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
}

.article-card h3 {
    margin: 15px 0 24px;
    font-size: clamp(18px, 1.5vw, 22px);
    line-height: 1.28;
    letter-spacing: -.25px;
    overflow-wrap: anywhere;
}

.article-card-footer {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

.article-card-footer span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.article-card-footer b {
    flex: none;
    color: var(--green);
}

/* Shared resilience for long text, URLs and compact screens. */
.content,
.panel,
.detail,
.customer-card,
.evaluation-detail,
.list-row > div {
    min-width: 0;
}

h1,
h2,
h3,
p,
td,
dd {
    overflow-wrap: anywhere;
}

.table-wrap {
    scrollbar-width: thin;
    scrollbar-color: #aebbb3 transparent;
}

.button,
button,
input,
select,
textarea {
    min-height: 44px;
}

.source-error-link {
    display: flex;
    width: max-content;
    align-items: center;
    gap: 7px;
    margin-top: 7px;
    padding: 6px 9px;
    border-radius: 8px;
    background: #f9dfdd;
    color: #8c2d29;
    font-size: 11px;
    font-weight: 800;
}

.source-error-link:hover {
    background: #f4cbc8;
}

.source-error-link b {
    font-size: 10px;
}

.source-error-link.compact {
    display: inline-flex;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: 10px;
}

.scoring-editor {
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--paper);
}

.scoring-editor summary {
    padding: 14px 16px;
    color: var(--green);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.scoring-editor[open] summary {
    border-bottom: 1px solid var(--line);
}

.scoring-editor label {
    padding: 16px 16px 0;
}

.scoring-editor textarea {
    min-height: 330px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1.55;
}

.scoring-editor p {
    margin: 10px 16px 16px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.analysis-box h3 {
    margin: 8px 0 12px;
    font-size: 20px;
}

.analysis-box p:not(.eyebrow) {
    font-size: 15px;
    line-height: 1.65;
}

/* Navigation: persistent sidebar on desktop, compact dropdown on mobile. */
.sidebar-menu {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
}

.menu-toggle {
    display: none;
    width: auto;
    min-height: 42px;
    align-items: center;
    gap: 9px;
    padding: 8px 11px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 10px;
    background: #1d392e;
    color: #fff;
    font-weight: 750;
    cursor: pointer;
}

.menu-toggle-icon {
    display: grid;
    width: 18px;
    gap: 4px;
}

.menu-toggle-icon i {
    display: block;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transition: transform .2s ease, opacity .2s ease;
}

.sidebar.menu-open .menu-toggle-icon i:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.sidebar.menu-open .menu-toggle-icon i:nth-child(2) {
    opacity: 0;
}

.sidebar.menu-open .menu-toggle-icon i:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

@media (max-width: 1100px) {
    .content {
        padding-inline: 30px;
    }

    .customer-card-head,
    .customer-summary {
        align-items: flex-start;
    }
}

@media (max-width: 900px) {
    body {
        overflow-x: hidden;
    }

    .app-shell {
        display: block;
    }

    .sidebar {
        position: sticky;
        z-index: 50;
        top: 0;
        display: flex;
        width: 100%;
        height: auto;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: max(10px, env(safe-area-inset-top)) 14px 10px;
        overflow: visible;
        box-shadow: 0 8px 28px rgba(9, 29, 21, .18);
    }

    .brand {
        margin: 0;
        gap: 9px;
    }

    .brand-mark {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    .brand small {
        display: none;
    }

    .menu-toggle {
        display: inline-flex;
    }

    .sidebar-menu {
        position: absolute;
        z-index: 60;
        top: calc(100% + 8px);
        right: 12px;
        left: 12px;
        display: none;
        max-height: calc(100vh - 90px);
        padding: 10px;
        overflow-y: auto;
        border: 1px solid rgba(255, 255, 255, .1);
        border-radius: 15px;
        background: var(--nav);
        box-shadow: 0 22px 55px rgba(6, 22, 16, .4);
    }

    .sidebar.menu-open .sidebar-menu {
        display: flex;
    }

    .sidebar nav {
        display: grid;
        gap: 4px;
    }

    .sidebar nav a,
    .sidebar .logout {
        width: 100%;
        min-height: 44px;
        align-items: center;
        padding: 11px 13px;
        font-size: 14px;
        white-space: normal;
    }

    .sidebar nav a {
        display: flex;
    }

    .sidebar nav a.active {
        background: var(--lime);
        color: var(--nav);
    }

    .sidebar .logout {
        display: flex;
        margin: 0;
        margin-top: 8px;
        border-top: 1px solid rgba(255, 255, 255, .12);
        border-radius: 0 0 9px 9px;
    }

    .content {
        padding: 22px 16px 54px;
    }

    .topbar {
        margin-bottom: 20px;
    }

    .topbar h1 {
        font-size: clamp(29px, 8vw, 39px);
        letter-spacing: -1px;
    }

    .status-pill {
        display: none;
    }

    .two-columns,
    .two-columns.wide-left,
    .customer-grid {
        grid-template-columns: 1fr;
    }

    .panel,
    .evaluation-detail {
        border-radius: 15px;
        padding: 18px;
    }

    .panel-head {
        flex-wrap: wrap;
        gap: 12px;
    }

    .filters,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .wide {
        grid-column: auto;
    }

    .table-wrap {
        width: calc(100% + 36px);
        margin-inline: -18px;
        padding: 0 18px 8px;
        overflow-x: auto;
    }

    table {
        min-width: 680px;
    }

    .detail {
        width: 100%;
        padding: 24px 20px;
    }

    .detail-actions {
        width: 100%;
        margin-top: 22px;
    }

    .detail-head {
        display: block;
    }

    .detail-head h2 {
        margin-top: 10px;
        font-size: clamp(28px, 8vw, 38px);
    }

    .detail-head form {
        margin-top: 20px;
    }

    .detail figure {
        margin: 25px 0;
    }

    .article-copy {
        font-size: 17px;
    }

    .article-copy .lead {
        font-size: 19px;
    }

    .meta {
        grid-template-columns: 1fr;
    }

    .customer-intro,
    .customer-summary {
        display: block;
        padding: 20px;
    }

    .customer-summary .button {
        margin-top: 10px;
    }

    .customer-intro .button {
        margin-top: 10px;
    }

    .customer-card {
        padding: 20px;
    }

    .customer-card-head {
        display: block;
    }

    .customer-card-head .button {
        margin-top: 12px;
    }

    .evaluation-head h2 {
        font-size: clamp(26px, 7vw, 34px);
    }

    .sent-preview dl {
        grid-template-columns: 78px 1fr;
    }

    .dedupe-hero {
        padding: 24px 20px;
    }

    .dedupe-hero h2 {
        font-size: 28px;
    }

    .review-actions,
    .customer-actions,
    .form-actions {
        flex-wrap: wrap;
    }

    .actions {
        min-width: 0;
        flex-wrap: wrap;
    }
}

/* Data-heavy pages become labelled cards instead of tiny, sideways tables. */
@media (max-width: 700px) {
    .table-wrap:has(.responsive-table) {
        width: 100%;
        margin-inline: 0;
        padding: 0;
        overflow: visible;
    }

    .responsive-table,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .responsive-table {
        min-width: 0;
    }

    .responsive-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    .responsive-table tbody {
        display: grid;
        gap: 12px;
    }

    .responsive-table tr {
        padding: 6px 14px;
        border: 1px solid var(--line);
        border-radius: 13px;
        background: #fff;
        box-shadow: 0 8px 22px rgba(29, 45, 37, .05);
    }

    .responsive-table td {
        position: relative;
        min-height: 42px;
        padding: 11px 0 11px 112px;
        border-top: 1px solid var(--line);
        text-align: left;
    }

    .responsive-table td:first-child {
        border-top: 0;
    }

    .responsive-table td::before {
        position: absolute;
        top: 12px;
        left: 0;
        width: 100px;
        color: var(--muted);
        content: attr(data-label);
        font-size: 9px;
        font-weight: 850;
        letter-spacing: .8px;
        line-height: 1.35;
        text-transform: uppercase;
    }

    .responsive-table td.actions {
        display: block;
    }

    .responsive-table .actions,
    .responsive-table .actions form {
        flex-wrap: wrap;
    }

    .responsive-table .actions .button {
        flex: 1 1 105px;
        min-height: 40px;
        padding: 8px 10px;
    }

    .responsive-table .source-actions .source-icon-button {
        flex: 0 0 44px;
        width: 44px;
        min-height: 44px;
        padding: 0;
    }

    .responsive-table .truncate {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 560px) {
    .content {
        padding-inline: 12px;
    }

    .topbar .eyebrow {
        font-size: 9px;
    }

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

    .stat-card {
        min-height: 142px;
        padding: 16px;
    }

    .stat-card strong {
        margin-top: auto;
        font-size: 34px;
    }

    .stat-card span,
    .stat-card small {
        font-size: 11px;
    }

    .panel,
    .evaluation-detail {
        padding: 16px;
    }

    .panel-head > .button {
        width: 100%;
    }

    .table-wrap {
        width: calc(100% + 32px);
        margin-inline: -16px;
        padding-inline: 16px;
    }

    .article-grid {
        gap: 14px;
    }

    .article-card-link > div.article-card-body {
        padding: 17px;
    }

    .article-card h3 {
        margin-bottom: 20px;
        font-size: 19px;
    }

    .list-row {
        align-items: flex-start;
    }

    .list-row .badge {
        flex: none;
    }

    .customer-settings {
        grid-template-columns: 1fr;
    }

    .customer-metrics {
        gap: 5px;
    }

    .customer-metrics div {
        padding: 10px;
    }

    .customer-metrics strong {
        font-size: 21px;
    }

    .customer-actions .button,
    .form-actions .button,
    .review-actions .button {
        flex: 1 1 140px;
    }

    .detail-send-form,
    .article-send-form {
        grid-template-columns: 1fr;
    }

    .detail-actions .button,
    .detail-actions select {
        width: 100%;
    }

    .list-row {
        flex-wrap: wrap;
    }

    .list-row > .actions {
        width: 100%;
    }

    .list-row > .actions form,
    .list-row > .actions .button {
        flex: 1 1 135px;
    }

    .article-result {
        display: grid;
        grid-template-columns: 1fr;
    }

    .article-result form,
    .article-result form .button,
    .customer-card-head .button {
        width: 100%;
    }

    .credential-card code {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .score-orb {
        width: 92px;
        height: 92px;
    }

    .sent-preview dl {
        display: block;
    }

    .sent-preview dt {
        margin-top: 12px;
    }

    .source-help {
        padding: 14px;
    }

    fieldset {
        padding: 14px;
    }

    .login-card {
        padding: 28px 22px;
        border-radius: 18px;
    }

    pre {
        margin-inline: -6px;
        padding: 14px;
        font-size: 11px;
    }
}

.filters.article-filters {
    grid-template-columns: minmax(210px, 2fr) minmax(145px, .85fr) minmax(145px, 1fr) minmax(155px, 1fr) minmax(155px, auto) auto;
}

.article-media-filter {
    min-height: 44px;
    align-self: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    white-space: nowrap;
}

@media (max-width: 1200px) {
    .filters.article-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filters.article-filters .button {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .filters.article-filters {
        grid-template-columns: 1fr;
    }

    .filters.article-filters .button {
        grid-column: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}

/* Mobile dashboard shell: a calm, full-width navigation surface. */
@media (max-width: 900px) {
    body.nav-open { overflow: hidden; }

    .sidebar {
        min-height: 64px;
        padding-inline: 12px;
    }

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

    .menu-toggle {
        min-width: 92px;
        justify-content: center;
    }

    .sidebar-menu {
        position: fixed;
        inset: var(--mobile-header-bottom, 64px) 0 0;
        max-height: none;
        padding: 14px 12px max(22px, env(safe-area-inset-bottom));
        border: 0;
        border-top: 1px solid rgba(255,255,255,.1);
        border-radius: 0;
        box-shadow: none;
        overscroll-behavior: contain;
    }

    .sidebar-menu nav { gap: 3px; }

    .sidebar .nav-section {
        margin: 18px 12px 6px;
        font-size: 10px;
    }

    .sidebar .nav-section:first-child { margin-top: 4px; }

    .sidebar .nav-customer {
        margin: 7px 0 0;
        border-color: rgba(255,255,255,.12);
        border-radius: 13px;
        background: rgba(255,255,255,.035);
    }

    .sidebar .nav-customer summary {
        min-height: 50px;
        padding: 13px 14px;
        font-size: 14px;
    }

    .sidebar .nav-customer > div {
        gap: 2px;
        padding: 0 7px 8px;
    }

    .sidebar .nav-customer > div a {
        min-height: 43px;
        padding: 10px 12px 10px 18px;
        border-left: 2px solid rgba(255,255,255,.1);
        border-radius: 8px;
        font-size: 13px;
    }

    .sidebar .nav-customer > div a.active {
        border-left-color: var(--lime);
    }

    .sidebar .logout { margin-top: 18px; }

    .topbar { align-items: flex-start; }
    .topbar h1 {
        max-width: 100%;
        font-size: clamp(25px, 7vw, 34px);
        line-height: 1.12;
        letter-spacing: -.8px;
    }

    .overview-intro { align-items: flex-start; }
    .customer-summary h2 { font-size: clamp(24px, 7vw, 29px); }

    .panel-head > form:not(.compact-filter),
    .panel-head > form:not(.compact-filter) .button {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .content { padding: 18px 10px 44px; }
    .topbar { margin-bottom: 16px; padding-inline: 3px; }

    .overview-intro,
    .customer-summary {
        margin-bottom: 14px;
        padding: 17px;
        border-radius: 14px;
    }

    .overview-intro h2 { font-size: 24px; }
    .overview-intro p:last-child,
    .customer-summary p:last-child { font-size: 13px; line-height: 1.5; }

    .stat-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .stat-card,
    .overview-stats .stat-card {
        min-height: 0;
        padding: 16px 17px;
    }

    .stat-card strong {
        margin: 7px 0 2px;
        font-size: 32px;
    }

    .panel,
    .evaluation-detail { border-radius: 14px; padding: 15px; }

    .panel-head { align-items: stretch; flex-direction: column; }
    .panel-head > a:not(.button) { display: inline-flex; min-height: 40px; align-items: center; }

    .responsive-table td {
        min-height: 0;
        padding: 9px 0;
    }

    .responsive-table td::before {
        position: static;
        display: block;
        width: auto;
        margin-bottom: 4px;
    }

    .responsive-table tr { padding: 7px 13px; }
    .responsive-table .inline-send,
    .responsive-table .inline-send .button { width: 100%; }

    .customer-metrics { grid-template-columns: 1fr; gap: 7px; }
    .customer-metrics div { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 10px; }
    .customer-metrics strong { font-size: 23px; }
    .customer-metrics span { font-size: 12px; }

    .form-actions,
    .customer-actions { flex-direction: column; }
    .form-actions .button,
    .customer-actions .button { width: 100%; flex-basis: auto; }

    .article-search-form .button,
    .article-url-form .button { width: 100%; }

    .pagination { flex-wrap: wrap; }
    .pagination a { min-height: 42px; display: inline-flex; align-items: center; }
}
