:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #0e1319;
    color: #f4efe3;
    --panel: #17202a;
    --panel-raised: #1d2935;
    --border: #43505c;
    --gold: #d2bc84;
    --muted: #b9c1c9;
    --danger: #ef9a9a;
    --success: #a7d7b4;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at top, #253544 0, #0e1319 40rem);
}

a { color: inherit; }

button,
.secondary-button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0.72rem 1rem;
    border: 1px solid var(--gold);
    border-radius: 0.55rem;
    background: var(--gold);
    color: #15191d;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.secondary-button:hover { filter: brightness(1.08); }
button:disabled { cursor: not-allowed; opacity: 0.55; }
.secondary-button { background: transparent; color: var(--gold); }

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 1rem max(1rem, calc((100vw - 76rem) / 2));
    border-bottom: 1px solid var(--border);
    background: rgba(11, 16, 21, 0.94);
    backdrop-filter: blur(12px);
}

.brand {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.35rem;
    font-weight: 800;
    text-decoration: none;
}

.site-header nav { display: flex; flex-wrap: wrap; gap: 1rem; }
.site-header nav a { color: var(--muted); font-weight: 700; text-decoration: none; }
.site-header nav a:hover { color: #fff; }

.page-shell {
    width: min(76rem, calc(100% - 2rem));
    margin: 0 auto;
    padding: 3rem 0 5rem;
}

.hero { margin-bottom: 3rem; }
.hero h1,
.dashboard-header h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(3rem, 8vw, 6rem);
    line-height: 0.95;
}
.hero > p:last-child,
.dashboard-header p { color: var(--muted); }
.compact-hero { margin-bottom: 1.5rem; }

.eyebrow {
    margin: 0 0 0.55rem;
    color: var(--gold);
    font-size: 0.76rem;
    font-weight: 850;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

h2, h3, p { margin-top: 0; }
h2 { margin-bottom: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.6rem, 4vw, 2.25rem); }
h3 { margin-bottom: 0.3rem; font-size: 1.2rem; }

.section-heading,
.dashboard-header,
.facility-card-header,
.cycle-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.section-heading { margin-bottom: 1rem; }
.section-heading.compact { align-items: flex-end; }

.profile-grid,
.overview-grid,
.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 1rem;
}

.profile-card,
.overview-card,
.facility-card,
.ledger-card,
.resource-card,
.cycle-banner,
.empty-state {
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    background: rgba(23, 32, 42, 0.94);
    box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.18);
}

.profile-card { display: grid; gap: 1rem; padding: 1.25rem; }
.profile-card p,
.overview-card p { margin-bottom: 0.25rem; color: var(--muted); }
.profile-card form button { width: 100%; }

.portrait {
    display: grid;
    width: 4.5rem;
    height: 4.5rem;
    place-items: center;
    border: 1px solid var(--gold);
    border-radius: 50%;
    background: #111820;
    color: var(--gold);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 2rem;
    font-weight: 800;
}
.portrait.small { width: 3rem; height: 3rem; font-size: 1.25rem; }

.dashboard-header {
    align-items: stretch;
    margin-bottom: 1rem;
}
.dashboard-header > div:first-child { flex: 1; }

.resource-card { display: grid; min-width: 10rem; align-content: center; gap: 0.3rem; padding: 1rem; }
.resource-card span { color: var(--muted); font-size: 0.85rem; }
.resource-card strong { font-size: 1.35rem; }
.resource-grid { margin-bottom: 2rem; }

.cycle-banner { margin-bottom: 2rem; padding: 1.1rem 1.25rem; }
.cycle-banner h2 { font-size: 1.5rem; }

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(18rem, 0.8fr);
    gap: 2rem;
    align-items: start;
}

.facility-card,
.overview-card,
.empty-state { padding: 1.25rem; }
.facility-card-header { align-items: flex-start; margin-bottom: 1rem; }
.facility-card-header p { color: var(--muted); }

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 800;
}
.status-ruined { border-color: #8e5c5c; color: #f1b1b1; }
.status-restoring { border-color: #9d8350; color: #ebd39c; }
.status-ready { border-color: #4d8060; color: #b2e0be; }

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin: 1.25rem 0; }
.facts div { padding: 0.8rem; border-radius: 0.65rem; background: #111820; }
.facts dt { color: var(--muted); font-size: 0.8rem; }
.facts dd { margin: 0.25rem 0 0; font-weight: 800; }

.confirmation-form { padding-top: 1rem; border-top: 1px solid var(--border); }
.confirmation-form p { color: var(--muted); }

.ledger-card { overflow: hidden; }
.ledger-row { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem; border-bottom: 1px solid var(--border); }
.ledger-row:last-child { border-bottom: 0; }
.ledger-row span { display: block; margin-top: 0.25rem; color: var(--muted); font-size: 0.78rem; }
.ledger-amount { text-align: right; color: var(--success); font-weight: 850; }
.ledger-amount.negative { color: var(--danger); }

.public-facility-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.empty-state { margin-top: 2rem; text-align: center; }
.empty-state p { margin: 0.7rem auto 0; color: var(--muted); }

.message-stack { display: grid; gap: 0.75rem; margin-bottom: 1.5rem; }
.message { padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: 0.65rem; background: var(--panel-raised); }
.message-success { border-color: #4d8060; }
.message-error { border-color: #8e5c5c; }

@media (max-width: 780px) {
    .page-shell { padding-top: 2rem; }
    .site-header,
    .dashboard-header,
    .section-heading { align-items: flex-start; flex-direction: column; }
    .site-header nav { font-size: 0.88rem; }
    .content-grid { grid-template-columns: 1fr; }
    .dashboard-header .resource-card { width: 100%; }
    .facts { grid-template-columns: 1fr; }
    .cycle-banner { align-items: flex-start; flex-direction: column; }
}

/* Milestone 1B: DM cycle management */
.nav-form { display: inline; margin: 0; }
.nav-button {
    min-height: auto;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    font-weight: 700;
}
.nav-button:hover { color: #fff; filter: none; }

.status-group,
.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}
.status-planning { border-color: #4d8060; color: #b2e0be; }
.status-locked { border-color: #9d8350; color: #ebd39c; }
.status-resolved { border-color: #62758a; color: #c5d4e3; }

.warning-card,
.auth-card,
.project-card,
.resolved-note {
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    background: rgba(23, 32, 42, 0.94);
}
.warning-card {
    margin-bottom: 2rem;
    padding: 1rem 1.25rem;
    border-color: #9d8350;
}
.warning-card p { margin: 0.35rem 0 0; color: var(--muted); }

.auth-shell {
    display: grid;
    min-height: 65vh;
    place-items: center;
}
.auth-card {
    width: min(30rem, 100%);
    padding: 2rem;
}
.auth-card h1 {
    margin: 0 0 0.75rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.5rem, 8vw, 4rem);
}
.auth-card > p:not(.eyebrow) { color: var(--muted); }
.stacked-form { display: grid; gap: 0.75rem; margin-top: 1.5rem; }
.stacked-form label { font-weight: 800; }
.stacked-form input {
    min-height: 46px;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.55rem;
    background: #0e151c;
    color: #fff;
    font: inherit;
}
.stacked-form button { margin-top: 0.5rem; }

.dm-cycle-banner { align-items: flex-end; }
.dm-cycle-banner p { margin: 0.4rem 0 0; color: var(--muted); }
.button-group form { margin: 0; }
.resolve-form button { border-color: #b76c6c; background: #b76c6c; color: #fff; }

.project-list { display: grid; gap: 1rem; }
.project-card { padding: 1.25rem; }
.project-card > div > p { color: var(--muted); }
.compact-empty { margin-top: 0; }
.section-block,
.spaced-heading { margin-top: 2rem; }
.card-copy { margin: 0; padding: 1rem; color: var(--muted); }
.activity-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}
.activity-row:last-child { border-bottom: 0; }
.activity-row span { color: var(--muted); font-size: 0.78rem; text-align: right; }
.resolved-note { margin-top: 1rem; padding: 0.9rem 1rem; color: var(--muted); }

@media (max-width: 780px) {
    .status-group,
    .button-group,
    .dm-cycle-banner { align-items: stretch; flex-direction: column; }
    .button-group form,
    .button-group button { width: 100%; }
    .activity-row { flex-direction: column; }
    .activity-row span { text-align: left; }
}

/* Milestone 1C: Basic Facility catalogue */
.section-copy,
.privacy-note,
.back-link,
.facility-detail-header > div > p,
.detail-panel > p,
.action-panel > p,
.active-project-banner p { color: var(--muted); }

.facility-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 1rem;
}
.facility-catalogue-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.facility-catalogue-card > p { margin: 0; color: var(--muted); }
.facility-catalogue-card .button-link { margin-top: auto; }
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gold);
    border-radius: 0.55rem;
    background: var(--gold);
    color: #111820;
    font-weight: 800;
    text-decoration: none;
}
.button-link:hover { filter: brightness(1.08); }
.button-link.secondary-button { background: transparent; color: #fff; }
.compact-facts { grid-template-columns: repeat(2, 1fr); }
.benefit-preview {
    padding: 0.85rem;
    border: 1px solid #4d8060;
    border-radius: 0.65rem;
    background: rgba(77, 128, 96, 0.08);
}
.benefit-preview p { margin: 0.35rem 0 0; color: var(--muted); }
.status-improving { border-color: #7b68a6; color: #d6c9f1; }
.status-ready { border-color: #4d8060; color: #b2e0be; }

.active-project-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 1.25rem;
    border: 1px solid var(--gold);
    border-radius: 0.9rem;
    background: rgba(182, 145, 72, 0.08);
}
.active-project-banner h2,
.active-project-banner p { margin: 0.25rem 0 0; }

.back-link {
    display: inline-block;
    margin-bottom: 1.5rem;
    font-weight: 800;
    text-decoration: none;
}
.facility-detail-header {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    align-items: flex-start;
    margin-bottom: 2rem;
}
.facility-detail-header h1 {
    margin: 0.2rem 0 0.7rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.8rem, 7vw, 5rem);
}
.large-status { padding: 0.7rem 1rem; font-size: 0.9rem; }
.facility-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.85fr);
    gap: 1.5rem;
    align-items: start;
}
.detail-panel,
.action-panel {
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    background: rgba(23, 32, 42, 0.94);
}
.detail-panel + .detail-panel { margin-top: 1rem; }
.detail-panel h2,
.action-panel h2 { margin: 0.3rem 0 0.8rem; }
.project-panel { border-color: var(--gold); }
.action-panel { position: sticky; top: 1rem; }
.action-panel button { width: 100%; }
.single-column-facts { grid-template-columns: 1fr; margin-bottom: 1rem; }

@media (max-width: 780px) {
    .facility-detail-grid { grid-template-columns: 1fr; }
    .facility-detail-header,
    .active-project-banner { align-items: stretch; flex-direction: column; }
    .action-panel { position: static; }
    .compact-facts { grid-template-columns: 1fr; }
}

/* Milestone 1D: Personal Special Facilities */
.section-block { margin-top: 3rem; }
.special-slot-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}
.special-slot-card { min-height: 15rem; }
.empty-special-slot {
    border-style: dashed;
    background: rgba(17, 24, 32, 0.72);
}
.facility-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
    gap: 1rem;
}
.facility-catalogue-card {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}
.facility-catalogue-card .button-link { margin-top: auto; }
.button-link {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0.72rem 1rem;
    border: 1px solid var(--gold);
    border-radius: 0.55rem;
    background: var(--gold);
    color: #15191d;
    font-weight: 800;
    text-decoration: none;
}
.section-copy,
.availability-note,
.card-copy,
.privacy-note,
.success-copy { color: var(--muted); }
.status-unbuilt { border-color: #62758a; color: #c5d4e3; }
.status-building { border-color: #9d8350; color: #ebd39c; }
.compact-dashboard-header h1,
.facility-detail-header h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.5rem, 7vw, 4.8rem);
    line-height: 1;
}
.facility-detail-header {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    align-items: flex-start;
    margin: 1.5rem 0 2rem;
}
.facility-detail-header > div { max-width: 50rem; }
.facility-detail-header > div > p:last-child { color: var(--muted); }
.facility-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(18rem, 0.8fr);
    gap: 2rem;
    align-items: start;
}
.detail-panel,
.action-panel,
.warning-card,
.active-project-banner {
    margin-bottom: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    background: rgba(23, 32, 42, 0.94);
}
.action-panel { position: sticky; top: 6rem; }
.back-link { display: inline-flex; margin-bottom: 0.75rem; color: var(--gold); font-weight: 800; text-decoration: none; }
.single-column-facts { grid-template-columns: 1fr; }
.checkbox-confirmation {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    margin-bottom: 1rem;
    color: var(--muted);
}
.checkbox-confirmation input { width: 1.15rem; height: 1.15rem; margin-top: 0.15rem; }
.benefit-preview {
    margin-top: 1rem;
    padding: 1rem;
    border-left: 3px solid var(--gold);
    background: #111820;
}
.benefit-preview p { margin: 0.4rem 0 0; color: var(--muted); }
.compact-facts { grid-template-columns: repeat(2, 1fr); margin: 0; }
.catalogue-level-section + .catalogue-level-section { padding-top: 1rem; }
.large-status { white-space: nowrap; }

@media (max-width: 780px) {
    .special-slot-grid,
    .facility-detail-grid { grid-template-columns: 1fr; }
    .facility-detail-header { flex-direction: column; }
    .action-panel { position: static; }
}


/* Milestone 1E: Shared treasury and Shared Special Facilities */
.shared-system-banner { border-color: #62758a; background: rgba(98, 117, 138, 0.1); }
.treasury-section { align-items: start; }
.large-balance { color: var(--gold); font-size: 1.5rem; }
.treasury-form {
    display: grid;
    gap: 0.7rem;
    margin-bottom: 1rem;
    padding: 1.1rem;
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    background: rgba(23, 32, 42, 0.94);
}
.treasury-form label { font-weight: 800; }
.treasury-form p { margin: 0; color: var(--muted); font-size: 0.88rem; }
.inline-form-row { display: flex; align-items: center; gap: 0.65rem; }
.inline-form-row input {
    min-width: 0;
    flex: 1;
    min-height: 44px;
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 0.55rem;
    background: #0e151c;
    color: #fff;
    font: inherit;
}
.compact-warning { margin: 0 0 1rem; }
.compact-project-list { gap: 0.75rem; }
.shared-facility-summary { display: grid; grid-template-columns: 1fr auto; gap: 0.75rem; align-items: start; }
.shared-facility-summary > p,
.shared-facility-summary > .button-link { grid-column: 1 / -1; }
.treasury-balance-line {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.85rem;
    border-radius: 0.65rem;
    background: #111820;
}
.treasury-balance-line span { color: var(--muted); }
.dm-treasury-heading { margin-top: 2rem; }
.treasury-ledger { margin-top: 1rem; }

@media (max-width: 780px) {
    .inline-form-row { align-items: stretch; flex-direction: column; }
    .inline-form-row button,
    .inline-form-row input { width: 100%; }
    .shared-facility-summary { grid-template-columns: 1fr; }
    .shared-facility-summary > p,
    .shared-facility-summary > .button-link { grid-column: auto; }
}

/* Milestone 2A: Facility orders, Strain, and Maintain */
.order-panel {
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    background: rgba(23, 32, 42, 0.96);
}
.order-panel-heading,
.order-card-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}
.order-panel-heading h2 { margin: 0; }
.strain-badge {
    display: inline-flex;
    min-height: 2rem;
    align-items: center;
    padding: 0.35rem 0.7rem;
    border: 1px solid #4d8060;
    border-radius: 999px;
    color: #b2e0be;
    font-size: 0.8rem;
    font-weight: 850;
    white-space: nowrap;
}
.strain-badge.strain-active { border-color: #9d8350; color: #ebd39c; }
.strain-badge.strain-critical { border-color: #8e5c5c; color: #f1b1b1; }
.facility-condition,
.current-order-card,
.order-coming-soon {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.7rem;
    background: #111820;
}
.facility-condition p,
.current-order-card p,
.order-coming-soon p { margin: 0.4rem 0 0; color: var(--muted); }
.condition-unusable,
.condition-strained,
.paused-order-card,
.project-paused { border-color: #8e5c5c; }
.status-active { border-color: #4d8060; color: #b2e0be; }
.status-paused { border-color: #8e5c5c; color: #f1b1b1; }
.current-order-card h3 { margin: 0.45rem 0 0; }
.current-order-card small,
.condition-admin-card small { display: block; margin-top: 0.7rem; color: var(--muted); }
.order-form {
    display: grid;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.order-form h3 { margin: 0; }
.order-form label { font-weight: 800; }
.order-form input[type="text"],
.order-form input[type="number"],
.order-form textarea,
.order-form select,
.compact-condition-form input {
    width: 100%;
    min-height: 44px;
    padding: 0.72rem;
    border: 1px solid var(--border);
    border-radius: 0.55rem;
    background: #0e151c;
    color: #fff;
    font: inherit;
}
.order-form textarea { resize: vertical; }
.order-form p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.order-form button { width: 100%; }
.maintain-form { margin-top: 1rem; border: 1px solid #9d8350; border-radius: 0.7rem; padding: 1rem; }
.input-suffix { display: flex; align-items: center; gap: 0.6rem; }
.input-suffix input { flex: 1; }
.order-history-panel { margin-top: 1rem; }
.order-history-list { display: grid; gap: 0.75rem; margin-top: 1rem; }
.order-history-row { padding: 0.9rem; border-radius: 0.65rem; background: #111820; }
.order-history-row span { display: block; margin-top: 0.25rem; color: var(--muted); font-size: 0.82rem; }
.order-history-row p { margin: 0.65rem 0 0; }
.facility-operation-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.65rem; }
.public-facility-row small { display: block; margin-top: 0.2rem; color: var(--muted); }
.dm-preflight-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem; align-items: start; }
.condition-note { margin: 0.8rem 0 0; color: var(--danger); }
.dm-result-card h3 { margin-bottom: 0.5rem; }
.condition-admin-list { display: grid; gap: 0.75rem; }
.condition-admin-card { padding: 1rem; border: 1px solid var(--border); border-radius: 0.75rem; background: rgba(23, 32, 42, 0.94); }
.condition-admin-card span { display: block; margin-top: 0.25rem; color: var(--muted); font-size: 0.8rem; }
.compact-condition-form { display: grid; gap: 0.6rem; margin-top: 0.8rem; }
.compact-condition-form button { width: 100%; }

@media (max-width: 900px) {
    .dm-preflight-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .order-panel-heading,
    .order-card-title { flex-direction: column; }
    .input-suffix { align-items: stretch; flex-direction: column; }
}
.improvement-action-panel { position: static; margin-top: 1rem; }

/* Milestone 2B: crafting catalogue and production records */
.inventory-grid,
.registry-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}
.inventory-card,
.registry-card {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    background: rgba(23, 32, 42, 0.96);
}
.inventory-card h3 { margin: 0; }
.inventory-card > p,
.registry-card span { color: var(--muted); }
.inventory-status-form,
.registry-form {
    display: grid;
    gap: 0.6rem;
    margin-top: 0.9rem;
}
.inventory-status-form select,
.registry-form input {
    width: 100%;
    min-height: 42px;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #0e151c;
    color: #fff;
    font: inherit;
}
.produced-items-panel { margin-top: 1.25rem; }
.produced-item-list { display: grid; gap: 0.75rem; margin-top: 1rem; }
.produced-item-row { padding: 0.9rem; border-radius: 0.65rem; background: #111820; }
.produced-item-row span { display: block; margin-top: 0.25rem; color: var(--muted); font-size: 0.82rem; }
.produced-item-row p { margin: 0.55rem 0 0; }
.crafting-registry-group { margin-top: 2rem; }
.registry-unpriced { border-color: #8e5c5c; }
.registry-form label,
.inventory-status-form label { font-weight: 800; }
.status-available { border-color: #4d8060; color: #b2e0be; }
.status-assigned { border-color: #7686a8; color: #c6d2ef; }
.status-consumed,
.status-lost { border-color: #8e5c5c; color: #f1b1b1; }

@media (max-width: 820px) {
    .inventory-grid,
    .registry-grid { grid-template-columns: 1fr; }
}

/* Milestone 2C: Bastion Charms and Empowerments */
.benefit-grid,
.benefit-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
    gap: 1rem;
}

.benefit-list { margin-top: 1rem; }

.benefit-card {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    background: #111820;
}

.benefit-card p { color: var(--muted); }
.benefit-card p:last-child { margin-bottom: 0; }
.benefit-grant-form { margin: 1rem 0; }
.status-unused { border-color: #4d8060; color: #b2e0be; }
.status-pending { border-color: #9d8350; color: #ebd39c; }
.status-expended,
.status-replaced,
.status-ended { border-color: #62758a; color: #c5d4e3; }
.dashboard-benefit-card form { margin-top: 1rem; }

/* Milestone 2D: facility holdings and expanded order forms */
.secondary-order-form {
    margin-top: 1rem;
    border-top: 1px solid var(--line, #d8d2c5);
    padding-top: 1rem;
}

.checkbox-fieldset {
    border: 1px solid var(--line, #d8d2c5);
    border-radius: 0.75rem;
    padding: 0.85rem;
    margin: 0.85rem 0;
}

.checkbox-fieldset legend {
    font-weight: 700;
    padding: 0 0.35rem;
}

.facility-assets-panel {
    margin-top: 1.25rem;
}

.asset-record-list {
    display: grid;
    gap: 0.75rem;
}

.asset-record-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.35rem 1rem;
    padding: 0.85rem;
    border: 1px solid var(--line, #d8d2c5);
    border-radius: 0.75rem;
}

.asset-record-row strong,
.asset-record-row span,
.asset-record-row small {
    display: block;
}

.asset-record-row p {
    grid-column: 1 / -1;
    margin: 0.35rem 0 0;
}

.asset-record-meta {
    text-align: right;
}

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

    .asset-record-meta {
        text-align: left;
    }
}

/* Milestone 3A: Bastion Defender companies and detachments */
.defender-company-panel { margin-top: 2rem; }
.defender-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}
.company-record-card { margin: 1rem 0 2rem; }
.detachment-grid,
.company-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
    gap: 1rem;
}
.detachment-card,
.detachment-admin-form {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    background: rgba(23, 32, 42, 0.96);
}
.detachment-card h3,
.detachment-admin-form h3 { margin: 0; }
.detachment-card small { display: block; color: var(--muted); margin-top: 0.55rem; }
.detachment-edit,
.new-detachment-row { margin-top: 0.9rem; }
.detachment-edit summary,
.new-detachment-row summary { cursor: pointer; font-weight: 800; }
.detachment-edit .order-form,
.new-detachment-row { padding-top: 0.75rem; }
.new-detachment-row + .new-detachment-row { border-top: 1px solid var(--border); }
.barrack-recruit-form fieldset { display: grid; gap: 0.55rem; }
.status-ready { border-color: #4d8060; color: #b2e0be; }
.status-worn { border-color: #9d8350; color: #ebd39c; }
.defender-admin-company + .defender-admin-company { margin-top: 1.25rem; }
.compact-detachment-grid { margin-top: 1rem; }

@media (max-width: 760px) {
    .defender-summary-grid { grid-template-columns: 1fr; }
}
.readonly-field {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.55rem;
    background: #111820;
    color: var(--muted);
}
.company-standing-form { max-width: 28rem; margin: 0.85rem 0 1rem; }

/* Milestone 3B: Deployments and DM finance */
.admin-link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
    gap: 1rem;
}

.admin-link-grid .active-project-banner { margin: 0; }
.deployment-config-form h2 { margin-top: 1.4rem; }
.choice-grid { display: grid; gap: 0.75rem; margin: 0.75rem 0 1rem; }
.radio-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.65rem;
    align-items: start;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    background: rgba(17, 24, 32, 0.75);
}
.radio-card input { margin-top: 0.25rem; }
.radio-card span { display: block; }
.form-grid-two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}
.form-grid-two > div { min-width: 0; }
.trait-context-option { align-items: start; }
.deploy-finalize-form { margin-top: 1rem; }
.deployment-resolution-card + .deployment-resolution-card { margin-top: 1rem; }
.consequence-fieldset { display: grid; gap: 0.55rem; }
.consequence-fieldset details {
    border: 1px solid var(--border);
    border-radius: 0.55rem;
    padding: 0.7rem;
}
.consequence-fieldset details summary { cursor: pointer; font-weight: 800; }
.status-awaiting_consequences { border-color: #9d8350; color: #ebd39c; }
.status-active { border-color: #587aa3; color: #c6dcf5; }
.status-completed { border-color: #4d8060; color: #b2e0be; }
.status-draft { border-color: #62758a; color: #c5d4e3; }
.danger-button {
    border-color: #8d4f4f;
    color: #f2c1c1;
    background: transparent;
}

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

/* Milestone 3C: Bastion Events, Alerts, and Fort Attacks */
.alert-grid,
.event-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
    gap: 1rem;
}

.alert-card,
.event-card,
.attack-loss-fieldset {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    background: rgba(23, 32, 42, 0.96);
}

.alert-card.priority-high { border-color: #8d7445; }
.alert-card.priority-urgent { border-color: #9a4e4e; }
.alert-card h3,
.event-card h3 { margin: 0; }
.acknowledged-note { color: var(--muted); font-weight: 700; }
.event-summary-banner { border-color: #587aa3; }
.compact-event-resolution { margin-top: 1rem; }
.attack-loss-fieldset { margin: 1rem 0; }
.attack-loss-fieldset legend { font-weight: 800; padding: 0 0.35rem; }
.loss-type-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.7rem;
    margin: 0.8rem 0;
}
.loss-type-grid label { margin: 0; }
.loss-type-grid input { margin-top: 0.35rem; }

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

@media (max-width: 520px) {
    .loss-type-grid { grid-template-columns: 1fr; }
}

/* Milestone 4 administration and rules reference */
.filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    align-items: end;
    margin: 1.25rem 0;
    padding: 1rem;
    border: 1px solid var(--border, #d8d2c4);
    border-radius: 0.75rem;
    background: var(--panel, #fffdf7);
}
.filter-bar label,
.order-form label {
    font-weight: 700;
}
.filter-bar input,
.filter-bar select,
.order-form input,
.order-form select,
.order-form textarea {
    width: 100%;
}
.profile-admin-grid,
.facility-admin-list,
.rules-article-list {
    display: grid;
    gap: 1rem;
}
.profile-admin-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.facility-admin-list {
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}
.administration-form {
    max-width: 760px;
}
.facility-admin-card details,
.rules-article-card details,
.audit-card details {
    margin-top: 0.85rem;
    border-top: 1px solid var(--border, #d8d2c4);
    padding-top: 0.75rem;
}
.facility-admin-card summary,
.rules-article-card summary,
.audit-card summary {
    cursor: pointer;
    font-weight: 800;
}
.rules-exact-text {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.035);
    line-height: 1.55;
    max-height: 70vh;
    overflow: auto;
}
.danger-zone,
.danger-form {
    border-color: #9f2d2d !important;
}
.danger-button {
    background: #8f2424;
    color: white;
    border-color: #8f2424;
}
.audit-card pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 0.4rem;
}
.lead-hireling-panel {
    margin-top: 1.25rem;
}

.public-access-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.public-access-shell .auth-card {
    width: min(100%, 34rem);
}
