/* --- RESET / BASE --- */
* {
    box-sizing: border-box;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    max-width: 1100px;
    margin: 40px auto;
    padding: 0 20px;
    line-height: 1.5;
    color: #1f2430;
    background: #f0f0f0;
}

/* --- HEADINGS --- */
h1 {
    margin-bottom: 20px;
    color: #1e2832;
}

h2 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 1.1rem;
    color: #1e2832;
}

/* --- LINKS --- */
a {
    color: #1e2832;
    text-decoration: none;
}

a:hover,
a:focus {
    text-decoration: underline;
}

/* --- TOP NAV --- */
.top-links {
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #1e2832;
    border-bottom: 3px solid #f4a62a;
}

.top-links a {
    color: #ffffff;
    font-weight: bold;
    margin-right: 16px;
}

.top-links a:hover,
.top-links a:focus {
    color: #f4a62a;
    text-decoration: none;
}

/* --- MESSAGES --- */
.message {
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid #8fb08f;
    background: #edf7ed;
    color: #1f2430;
}

.error {
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid #b97a7a;
    background: #f8eaea;
    color: #1f2430;
}

.meta {
    margin-bottom: 20px;
    color: #5b6470;
}

/* --- SECTIONS --- */
.section {
    border: 1px solid #cfd6dd;
    padding: 18px;
    background: #ffffff;
    margin-bottom: 24px;
}

/* --- FORMS --- */
form.main-form {
    display: grid;
    gap: 18px;
}

.field {
    display: grid;
    gap: 6px;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 700px) {
    .field-row {
        grid-template-columns: 1fr;
    }
}

label {
    font-weight: bold;
    color: #1e2832;
}

/* --- INPUTS --- */
input[type="text"],
input[type="date"],
input[type="search"],
select,
textarea {
    padding: 10px;
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #b8c1cb;
    background: #ffffff;
    color: #1f2430;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #f4a62a;
    box-shadow: 0 0 0 2px rgba(244, 166, 42, 0.18);
}

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

/* --- BUTTONS --- */
button,
input[type="submit"],
input[type="button"],
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 14px;
    border: 1px solid #1e2832;
    background: #1e2832;
    color: #ffffff;
    text-decoration: none;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1.2;
    font-family: Arial, Helvetica, sans-serif;
    vertical-align: middle;
    appearance: none;
    -webkit-appearance: none;
}

button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
.button-link:hover,
button:focus,
input[type="submit"]:focus,
input[type="button"]:focus,
.button-link:focus {
    background: #2b3948;
    border-color: #2b3948;
    color: #ffffff;
    text-decoration: none;
    outline: none;
}

/* --- ACTIONS --- */
.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* --- SEARCH / INLINE --- */
.inline-form {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.inline-form input[type="text"],
.inline-form input[type="search"] {
    max-width: 420px;
}

/* --- TABLES --- */
table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
}

th,
td {
    text-align: left;
    vertical-align: top;
    padding: 10px;
    border-bottom: 1px solid #d8dee5;
}

th {
    background: #1e2832;
    color: #ffffff;
}

/* --- SMALL TEXT --- */
.small {
    font-size: 0.9rem;
    color: #5b6470;
}

.muted {
    color: #66707c;
    font-size: 0.95rem;
}

/* --- BOXES --- */
.selected-box,
.result-box,
.relation-box {
    padding: 10px;
    border: 1px solid #c7cfd8;
    background: #ffffff;
    margin-bottom: 10px;
}

.selected-box {
    border-left: 4px solid #f4a62a;
}

/* --- TITLES --- */
.result-title,
.relation-title {
    font-weight: bold;
    color: #1e2832;
}

/* --- SEARCH RESULTS --- */
.results {
    margin-top: 12px;
    border-top: 1px solid #cfd6dd;
    padding-top: 12px;
}

/* --- EMPTY STATE --- */
.empty {
    padding: 16px;
    border: 1px solid #d6dbe1;
    background: #fafbfc;
}

/* --- FOOTER --- */
.site-footer {
    margin: 24px 0 10px 0;
    padding: 14px 16px;
    border-top: 1px solid #cfd6dd;
    color: #5b6470;
}

.site-footer-inner {
    text-align: center;
}

/* =========================================================
   PUBLIC PAGES
   ========================================================= */

.public-page {
    max-width: 1100px;
}

.public-intro {
    margin-bottom: 20px;
    color: #5b6470;
}

.public-search-box {
    margin-bottom: 24px;
}

.public-results {
    display: grid;
    gap: 16px;
}

.public-result-card {
    padding: 16px 18px;
    border: 1px solid #cfd6dd;
    background: #ffffff;
}

.public-result-name {
    margin: 0 0 6px 0;
    font-size: 1.2rem;
    font-weight: bold;
    color: #1e2832;
}

.public-result-meta {
    font-size: 0.92rem;
    color: #66707c;
    margin-bottom: 10px;
}

.public-result-note {
    color: #2d3440;
    margin-bottom: 12px;
}

.public-result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.public-profile-header {
    margin-bottom: 24px;
    padding-bottom: 14px;
    border-bottom: 2px solid #d6dde4;
}

.public-profile-title {
    margin: 0 0 8px 0;
    font-size: 2rem;
    line-height: 1.2;
    color: #1e2832;
}

.public-profile-mid {
    font-size: 0.95rem;
    color: #66707c;
}

.public-profile-section {
    margin-bottom: 28px;
    padding: 18px;
    border: 1px solid #cfd6dd;
    background: #ffffff;
}

.public-profile-section h2 {
    margin-top: 0;
    margin-bottom: 14px;
    font-size: 1.15rem;
    color: #1e2832;
    border-bottom: 1px solid #e2e7ec;
    padding-bottom: 8px;
}

.public-identity p {
    margin-bottom: 10px;
}

.public-scope-note {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e2e7ec;
    color: #66707c;
    font-size: 0.95rem;
}

.public-production {
    padding: 14px 16px;
    border: 1px solid #d7dde4;
    background: #fcfcfd;
    margin-bottom: 18px;
}

.public-production:last-child {
    margin-bottom: 0;
}

.public-production-title {
    margin: 0 0 8px 0;
    font-weight: bold;
    font-size: 1.08rem;
    color: #1e2832;
}

.public-production-line {
    margin-bottom: 6px;
}

.public-production-line:last-child {
    margin-bottom: 0;
}

.public-production-mid {
    margin-top: 8px;
    font-size: 0.92rem;
    color: #66707c;
}

.public-items {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #e0e5ea;
}

.public-items-title {
    margin: 0 0 10px 0;
    font-weight: bold;
    color: #1e2832;
}

.public-item {
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid #d8dee5;
    background: #ffffff;
}

.public-item:last-child {
    margin-bottom: 0;
}

.public-item-line {
    color: #2d3440;
    word-break: break-word;
}

.pagination {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 18px;
}

.pagination .current-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    min-width: 42px;
    padding: 10px 14px;
    border: 1px solid #c4ccd5;
    background: #e9edf1;
    color: #1e2832;
    font-weight: bold;
}

/* --- PRINT DOCUMENT HEADER --- */
.print-header {
    display: none;
}

.print-title {
    display: none;
}

/* --- PRINT --- */
@media print {
    @page {
        margin: 10mm;
    }

    body {
        background: #ffffff;
        color: #000000;
        font-size: 11pt;
        line-height: 1.25;
        margin: 0;
        padding: 0;
        max-width: none;
    }

    .top-links,
    .actions,
    .button-link,
    button,
    input[type="submit"],
    input[type="button"],
    .no-print {
        display: none !important;
    }

    .print-header {
        display: block;
        text-align: center;
        margin-bottom: 10px;
        padding-bottom: 6px;
        border-bottom: 1px solid #000;
        font-size: 11pt;
        line-height: 1.3;
    }

    .print-header div {
        margin-bottom: 2px;
    }

    .print-header div:first-child {
        font-weight: bold;
    }

    .print-title {
        display: block;
        text-align: center;
        font-size: 14pt;
        font-weight: bold;
        margin: 8px 0 12px 0;
    }

    h1 {
        font-size: 18pt;
        margin-bottom: 4px;
        color: #000000;
    }

    h2 {
        font-size: 14pt;
        margin-top: 14px;
        margin-bottom: 6px;
        border-bottom: 1px solid #000;
        padding-bottom: 3px;
        color: #000000;
    }

    .meta {
        font-size: 10pt;
        margin-bottom: 8px;
        color: #000000;
    }

    .section {
        border: none;
        padding: 0;
        margin-bottom: 12px;
        background: #ffffff;
    }

    .relation-box {
        border: none;
        border-top: 1px solid #000;
        padding: 6px 0;
        margin-top: 10px;
        background: #ffffff;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .relation-title {
        font-weight: bold;
        font-size: 12pt;
        margin-bottom: 2px;
        color: #000000;
    }

    .selected-box {
        border: none;
        border-left: none;
        padding: 1px 0 1px 10px;
        margin: 0;
        font-size: 10.5pt;
        background: #ffffff;
        color: #000000;
    }

    .results {
        margin-top: 4px;
        padding-top: 2px;
        border-top: 1px dotted #999;
    }

    .result-title {
        font-weight: bold;
        font-size: 11pt;
        margin-bottom: 2px;
        color: #000000;
    }

    .section,
    .relation-box,
    .result-box,
    .selected-box {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    a {
        color: #000000;
        text-decoration: none;
    }
}

/* --- RESPONSIVE --- */
@media (max-width: 700px) {
    body {
        margin: 20px auto;
        padding: 0 14px;
    }

    .top-links {
        padding: 10px 12px;
    }

    .top-links a {
        display: inline-block;
        margin-right: 12px;
        margin-bottom: 6px;
    }

    .actions,
    .public-result-actions,
    .pagination {
        gap: 8px;
    }

    .public-profile-title {
        font-size: 1.6rem;
    }
}
/* =========================================================
   STATS (public index)
   ========================================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 12px;
}

.stat-box {
    padding: 16px;
    border: 1px solid #cfd6dd;
    background: #ffffff;
    text-align: center;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: bold;
    color: #1e2832;
}

.stat-label {
    margin-top: 6px;
    color: #5b6470;
}

@media (max-width: 700px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}