:root {
    --ink: #0f172a;
    --muted: #64748b;
    --line: rgba(15, 23, 42, .12);
    --green: #16a34a;
    --green-dark: #047857;
    --gold: #f59e0b;
    --red: #dc2626;
    --shadow: 0 16px 36px rgba(15, 23, 42, .14);
    --radius: 20px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    line-height: 1.65;
    color: var(--ink);
}

a {
    text-decoration: none;
    color: var(--green-dark);
    font-weight: 800;
}

button {
    border: none;
    border-radius: 12px;
    padding: 11px 16px;
    background: linear-gradient(90deg, #047857, #16a34a);
    color: #fff;
    font-weight: 900;
    cursor: pointer;
}

button:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 11px 12px;
    font: inherit;
    background: #fff;
    color: var(--ink);
}

textarea {
    resize: vertical;
}

.kicker {
    margin: 0 0 6px;
    color: #fde68a;
    letter-spacing: .12em;
    text-transform: uppercase;
    font-weight: 900;
    font-size: .8rem;
}

.muted {
    color: var(--muted);
    margin: 0 0 14px;
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 16px;
    font-weight: 800;
}

.alert.success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.empty-box,
.notice-box {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    padding: 14px;
    color: #475569;
    margin: 12px 0;
}

.admin-body,
.portal-body {
    background:
        radial-gradient(circle at top left, rgba(22, 163, 74, .18), transparent 30%),
        radial-gradient(circle at top right, rgba(245, 158, 11, .16), transparent 32%),
        #f1f5f9;
}

.admin-wrap,
.portal-main {
    max-width: 1320px;
    margin: 0 auto;
    padding: 24px;
}

.admin-hero {
    border-radius: 28px;
    background: linear-gradient(135deg, #07111f, #14532d 60%, #92400e);
    color: #fff;
    padding: 30px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    margin-bottom: 20px;
}

.admin-hero h1 {
    margin: 0 0 8px;
    font-size: clamp(1.7rem, 4vw, 3rem);
    line-height: 1.1;
}

.admin-hero p {
    margin: 0;
    color: #e2e8f0;
}

.admin-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.admin-actions a {
    display: inline-flex;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .18);
}

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

.stat-card,
.panel-card,
.filter-card,
.thread-card,
.form-card,
.lookup-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 18px;
}

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

.stat-card strong {
    font-size: 1.7rem;
    color: #14532d;
}

.panel-card,
.thread-card,
.form-card,
.lookup-card {
    padding: 22px;
    margin-bottom: 20px;
}

.filter-card {
    padding: 16px;
    margin-bottom: 18px;
}

.filter-form,
.lookup-form {
    display: grid;
    grid-template-columns: 1fr 230px 230px 130px;
    gap: 12px;
}

.lookup-form {
    grid-template-columns: 1fr 1fr 1fr 150px;
}

.lookup-form.two {
    grid-template-columns: 1fr 1fr 150px;
}

.form-grid {
    display: grid;
    gap: 12px;
}

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

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

.form-group label {
    display: block;
    font-weight: 900;
    color: #334155;
    margin-bottom: 6px;
}

.form-group.full {
    grid-column: 1 / -1;
}

.large-form h2 {
    margin: 24px 0 10px;
    color: #14532d;
}

.large-form h2:first-child {
    margin-top: 0;
}

.linked-box {
    margin-top: 14px;
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: #166534;
    border-radius: 14px;
    padding: 14px;
}

.thread-grid {
    display: grid;
    gap: 18px;
}

.thread-card.focused {
    outline: 4px solid rgba(22, 163, 74, .28);
}

.card-top {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.card-top h2,
.card-top h3 {
    margin: 0;
    color: #0f172a;
    line-height: 1.25;
}

.card-top p {
    margin: 4px 0 0;
    color: #64748b;
}

.badge-stack {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: .78rem;
    font-weight: 900;
    white-space: nowrap;
    background: #e2e8f0;
    color: #334155;
}

.badge.approved {
    background: #dcfce7;
    color: #166534;
}

.badge.processing {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge.disputed {
    background: #fae8ff;
    color: #86198f;
}

.badge.rejected {
    background: #fee2e2;
    color: #991b1b;
}

.badge.closed {
    background: #e2e8f0;
    color: #334155;
}

.badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.info-grid div {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px;
    min-width: 0;
}

.info-grid span {
    display: block;
    color: #64748b;
    font-size: .78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.info-grid strong {
    display: block;
    color: #0f172a;
    overflow-wrap: anywhere;
}

.contact-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 14px 0;
}

.contact-actions a,
.attachment-link {
    display: inline-flex;
    padding: 9px 12px;
    border-radius: 12px;
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #bbf7d0;
}

.thread-form,
.reply-form {
    border-top: 1px solid #e2e8f0;
    margin-top: 16px;
    padding-top: 16px;
}

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 12px 18px 12px 0;
    font-weight: 800;
    color: #334155;
}

.inline-check input {
    width: auto;
}

.conversation {
    display: grid;
    gap: 12px;
    margin: 16px 0;
}

.message-bubble {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 14px;
    border-left: 5px solid #94a3b8;
}

.message-bubble.buyer {
    border-left-color: #2563eb;
}

.message-bubble.vendor {
    border-left-color: #16a34a;
}

.message-bubble.admin {
    border-left-color: #f59e0b;
}

.message-bubble.system {
    border-left-color: #7c3aed;
}

.message-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #64748b;
    font-size: .9rem;
}

.message-meta strong {
    color: #0f172a;
}

.message-bubble p {
    margin: 8px 0;
    color: #334155;
}

.public-body {
    background: linear-gradient(135deg, #07111f, #14532d 52%, #7c2d12);
    color: #fff;
    min-height: 100vh;
}

.public-header,
.portal-header {
    max-width: 1320px;
    margin: 0 auto;
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.portal-header {
    max-width: none;
    background: #07111f;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 50;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
}

.brand img {
    width: 46px;
    height: 46px;
    object-fit: contain;
    background: #fff;
    border-radius: 12px;
    padding: 4px;
}

.public-header nav,
.portal-header nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.public-header nav a,
.portal-header nav a {
    color: #fff;
    background: rgba(255, 255, 255, .12);
    padding: 9px 12px;
    border-radius: 12px;
}

.public-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 18px 48px;
}

.public-hero {
    border-radius: 28px;
    background: rgba(255, 255, 255, .10);
    border: 1px solid rgba(255, 255, 255, .18);
    padding: 30px;
    box-shadow: var(--shadow);
    text-align: center;
    margin-bottom: 20px;
}

.public-hero h1 {
    margin: 0 0 8px;
    font-size: clamp(1.8rem, 4vw, 3rem);
    line-height: 1.1;
    color: #fff;
}

.public-hero p {
    margin: 0;
    color: #e2e8f0;
}

.lookup-card,
.form-card,
.thread-card {
    color: #0f172a;
}

.vendor-card {
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .20);
    border-radius: 18px;
    padding: 18px;
    min-width: 260px;
}

.vendor-card strong,
.vendor-card span {
    display: block;
    color: #fff;
}

.vendor-card span {
    color: #fde68a;
}

@media (max-width: 1120px) {
    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

@media (max-width: 820px) {
    .admin-wrap,
    .portal-main {
        padding: 14px;
    }

    .admin-hero {
        display: block;
    }

    .admin-actions {
        justify-content: flex-start;
        margin-top: 14px;
    }

    .filter-form,
    .lookup-form,
    .lookup-form.two,
    .form-grid.two,
    .form-grid.three,
    .stats-grid,
    .info-grid {
        grid-template-columns: 1fr;
    }

    .card-top,
    .message-meta {
        display: block;
    }

    .badge-stack {
        justify-content: flex-start;
        margin-top: 10px;
    }

    .public-header,
    .portal-header {
        display: block;
    }

    .public-header nav,
    .portal-header nav {
        margin-top: 12px;
    }
}
