:root {
    --ink: #19211d;
    --muted: #657069;
    --line: #d8ded9;
    --surface: #ffffff;
    --subtle: #f4f6f4;
    --accent: #176b4d;
    --accent-dark: #0f5139;
    --warning: #8a6410;
    --danger: #9b3730;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: #eef1ef;
    color: var(--ink);
    font: 14px/1.45 Arial, Helvetica, sans-serif;
}

a { color: var(--accent-dark); }

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    background: var(--accent);
    color: white;
    font-weight: 700;
}

.brand strong, .brand small { display: block; }
.brand small, .local-label, .subtle, .muted-cell { color: var(--muted); }
.primary-nav { display: flex; align-items: center; gap: 18px; }
.primary-nav a { color: var(--muted); font-weight: 700; text-decoration: none; }
.primary-nav a:hover { color: var(--accent); }
.page-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 48px; }

.page-heading, .section-heading, .company-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 20px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 30px; letter-spacing: 0; }
h2 { margin-bottom: 8px; font-size: 19px; letter-spacing: 0; }
h3 { margin-bottom: 4px; font-size: 15px; letter-spacing: 0; }
.eyebrow { margin-bottom: 5px; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

.search-form { width: min(520px, 100%); }
.search-form label { display: block; margin-bottom: 5px; font-weight: 700; }
.search-row, .action-group { display: flex; align-items: center; gap: 8px; }

input {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid #aeb8b1;
    background: white;
    color: var(--ink);
}
select, textarea {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid #aeb8b1;
    background: white;
    color: var(--ink);
    font: inherit;
}
textarea { resize: vertical; }

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid var(--accent);
    border-radius: 4px;
    background: var(--accent);
    color: white;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

button:hover, .button:hover { background: var(--accent-dark); }
.button.secondary { border-color: #aeb8b1; background: white; color: var(--ink); }
.button.secondary:hover { background: var(--subtle); }
.button.danger-link, .danger-button { border-color: var(--danger); background: white; color: var(--danger); }
.button.danger-link:hover, .danger-button:hover { background: #f9eceb; }

.table-region, .section-band, .detail-section, .json-region, .empty-state {
    border: 1px solid var(--line);
    background: var(--surface);
}

.table-region { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--subtle); color: var(--muted); font-size: 11px; text-align: left; text-transform: uppercase; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8faf8; }
.company-link { color: var(--ink); font-weight: 700; text-decoration: none; }
.company-link:hover { color: var(--accent); text-decoration: underline; }

.status {
    display: inline-block;
    padding: 3px 7px;
    border: 1px solid #c3cbc5;
    border-radius: 3px;
    background: #f2f4f2;
    color: #4f5a53;
    font-size: 11px;
    font-weight: 700;
    text-transform: capitalize;
    white-space: nowrap;
}

.status-success { border-color: #9cc8b2; background: #e7f3ec; color: var(--accent-dark); }
.status-failed_http, .status-failed_captcha_or_interstitial, .status-failed_timeout, .status-failed_connection, .status-failed_invalid_website, .status-failed_unknown, .status-archived { border-color: #ddb0ab; background: #f9eceb; color: var(--danger); }
.status-never_run { color: var(--muted); }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0; }
.metric { padding: 13px 14px; border: 1px solid var(--line); background: var(--surface); }
.metric span, .metric small { display: block; color: var(--muted); }
.metric strong { display: block; margin: 5px 0 3px; font-size: 19px; }
.nav-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0; }
.nav-grid-five { grid-template-columns: repeat(5, 1fr); }
.nav-grid-six { grid-template-columns: repeat(6, 1fr); }
.nav-panel { min-height: 112px; padding: 16px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; }
.nav-panel:hover { border-color: var(--accent); background: #f8faf8; }
.nav-panel strong, .nav-panel span { display: block; }
.nav-panel strong { margin-bottom: 8px; font-size: 17px; }
.nav-panel span { color: var(--muted); }

.section-band { padding: 18px; }
.section-heading { align-items: start; margin-bottom: 12px; }
.section-heading p:last-child { max-width: 420px; color: var(--muted); }
.view-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 0; border-top: 1px solid var(--line); }
.view-row p { margin-bottom: 0; color: var(--muted); }
.view-row form { margin: 0; }
.row-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.summary-grid div { min-width: 0; padding: 13px 14px 13px 0; }
.summary-grid span, .summary-grid strong { display: block; overflow-wrap: anywhere; }
.summary-grid span { margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.inline-empty { padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); }
.status-list { border: 1px solid var(--line); background: var(--surface); }
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.status-row:last-child { border-bottom: 0; }
.status-row strong, .status-row span { display: block; }
.status-row div span { margin-top: 3px; color: var(--muted); }
.plain-list { margin: 0 0 18px; padding-left: 18px; }
.plain-list li { margin-bottom: 5px; }
.market-block { padding: 0 0 16px; border-top: 1px solid var(--line); }
.market-block:first-child { border-top: 0; }
.market-block .view-row { border-top: 0; }
.market-block dl { margin: 0; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.detail-section { padding: 18px; }
dl { display: grid; grid-template-columns: 150px 1fr; margin: 14px 0 0; }
dt, dd { padding: 8px 0; border-top: 1px solid var(--line); }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; font-weight: 700; }

.breadcrumb { display: flex; gap: 8px; margin-bottom: 20px; color: var(--muted); font-size: 12px; }
.notice { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; padding: 13px 15px; border: 1px solid #d7c174; background: #fff8dc; }
.notice p { margin: 3px 0 0; color: #685313; }
.error-notice { border-color: #ddb0ab; background: #f9eceb; }
.error-notice p { color: var(--danger); }
.success-notice { margin-bottom: 18px; padding: 11px 14px; border: 1px solid #9cc8b2; background: #e7f3ec; color: var(--accent-dark); font-weight: 700; }
.list-tools { display: flex; align-items: end; gap: 12px; }
.registry-form, .confirm-panel { padding: 18px; border: 1px solid var(--line); background: var(--surface); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid label span { display: block; margin-bottom: 5px; font-weight: 700; }
.form-grid .wide-field { grid-column: 1 / -1; }
.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field input { width: auto; min-height: auto; }
.checkbox-field span { margin: 0 !important; }
.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.form-actions form { margin: 0; }
.empty-state { padding: 48px 24px; text-align: center; }
.json-region { overflow: auto; }
pre { margin: 0; padding: 18px; font: 12px/1.55 Consolas, "Courier New", monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 820px) {
    .app-header { padding: 0 16px; }
    .primary-nav { gap: 10px; font-size: 12px; }
    .page-heading, .section-heading, .company-heading { display: block; }
    .list-tools { align-items: stretch; flex-direction: column; margin-top: 18px; }
    .search-form { margin-top: 18px; }
    .metric-grid, .detail-grid, .nav-grid, .nav-grid-five, .nav-grid-six, .summary-grid { grid-template-columns: 1fr 1fr; }
    .view-row { align-items: start; }
}

@media (max-width: 560px) {
    .page-shell { width: min(100% - 20px, 1180px); padding-top: 18px; }
    .app-header { align-items: start; flex-direction: column; gap: 10px; padding-top: 12px; padding-bottom: 12px; }
    .primary-nav { width: 100%; justify-content: space-between; gap: 6px; }
    .search-row, .action-group, .view-row, .notice, .row-meta { align-items: stretch; flex-direction: column; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .wide-field { grid-column: auto; }
    .metric-grid, .detail-grid, .nav-grid, .nav-grid-five, .nav-grid-six, .summary-grid { grid-template-columns: 1fr; }
    dl { grid-template-columns: 1fr; }
    dd { padding-top: 0; border-top: 0; }
}
