:root {
    color-scheme: light;
    --ink: #152724;
    --muted: #5c6d69;
    --surface: #ffffff;
    --surface-soft: #f2f6f5;
    --line: #cedbd8;
    --brand: #1f4f46;
    --brand-dark: #143b34;
    --accent: #c98c2c;
    --danger: #a42d35;
    --danger-dark: #7d2027;
    --success-bg: #e4f4eb;
    --success-ink: #145b36;
    --error-bg: #fbe8e8;
    --error-ink: #842029;
    --shadow: 0 14px 36px rgba(21, 39, 36, 0.08);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #e9efed; }
body { margin: 0; color: var(--ink); background: linear-gradient(180deg, #f8faf9 0, #eef3f1 100%); min-height: 100vh; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-dark); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #d69b3e; outline-offset: 3px; }

.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 10px 14px; background: #fff; transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.shell { width: min(1440px, calc(100% - 40px)); margin: 0 auto; }

.site-header { background: var(--brand); color: #fff; box-shadow: 0 3px 20px rgba(11, 38, 32, 0.16); }
.header-inner { min-height: 76px; display: flex; align-items: center; gap: 34px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: #fff; font-weight: 750; font-size: 1.05rem; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 36px; border-radius: 11px; background: var(--accent); color: #1f2d2a; font-size: 0.9rem; font-weight: 900; letter-spacing: 0.035em; text-decoration: none; }
.brand-mark:hover { color: #1f2d2a; background: #dfa23f; }
.brand-copy { display: grid; gap: 1px; color: #fff; text-decoration: none; }
.brand-copy:hover { color: #fff; }
.brand-copy strong { line-height: 1; letter-spacing: 0.025em; }
.brand-copy small { color: #cfe0dc; font-size: 0.75rem; font-weight: 650; }
.primary-nav { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.primary-nav > a, .nav-dropdown > summary { color: #eff8f5; text-decoration: none; padding: 10px 11px; border-radius: 8px; font-size: 0.94rem; }
.primary-nav > a:hover, .nav-dropdown > summary:hover, .nav-dropdown[open] > summary { color: #fff; background: rgba(255, 255, 255, 0.11); }
.primary-nav > .developer-nav-link { margin-left: auto; border: 1px solid rgba(255, 255, 255, 0.32); }
.primary-nav > .developer-nav-link[aria-current="page"] { color: #1f2d2a; background: var(--accent); border-color: var(--accent); }
.nav-dropdown { position: relative; }
.nav-dropdown > summary { display: flex; align-items: center; gap: 7px; cursor: pointer; list-style: none; }
.nav-dropdown > summary::-webkit-details-marker { display: none; }
.nav-dropdown > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform 120ms ease; }
.nav-dropdown[open] > summary::after { transform: translateY(2px) rotate(225deg); }
.nav-dropdown-menu { position: absolute; z-index: 20; top: calc(100% + 8px); left: 0; min-width: 220px; display: grid; gap: 3px; padding: 8px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: 0 16px 38px rgba(11, 38, 32, 0.22); }
.nav-dropdown-menu a { padding: 10px 12px; border-radius: 7px; color: var(--ink); font-size: 0.92rem; font-weight: 650; text-decoration: none; white-space: nowrap; }
.nav-dropdown-menu a:hover { color: var(--brand-dark); background: var(--surface-soft); }
.user-area { display: flex; align-items: center; gap: 12px; margin-left: auto; padding-left: 10px; white-space: nowrap; }
.user-area > span { display: grid; text-align: right; }
.user-area strong { color: #fff; font-size: 0.85rem; }
.user-area small { color: #cfe0dc; font-size: 0.72rem; }
.user-area form { margin: 0; }
.header-logout { min-height: 34px; border: 1px solid rgba(255, 255, 255, 0.38); border-radius: 8px; padding: 6px 10px; color: #fff; background: transparent; font-size: 0.82rem; font-weight: 700; cursor: pointer; }
.header-logout:hover { background: rgba(255, 255, 255, 0.12); }

.page-content { padding: 44px 0 72px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; }
.page-heading.compact { align-items: center; }
.page-heading h1 { margin: 4px 0 5px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 4vw, 3.35rem); line-height: 1.05; font-weight: 600; letter-spacing: -0.035em; }
.page-heading.compact h1 { font-size: clamp(1.9rem, 3vw, 2.7rem); }
.eyebrow { margin: 0; color: #8a5a16; text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.75rem; font-weight: 800; }
.lede { margin: 0; color: var(--muted); max-width: 720px; }
.heading-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.login-layout { min-height: calc(100vh - 205px); display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(340px, 480px); align-items: center; gap: clamp(40px, 9vw, 130px); }
.login-intro h1 { max-width: 760px; margin: 10px 0 20px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.5rem, 5.6vw, 5.7rem); line-height: 0.98; font-weight: 600; letter-spacing: -0.05em; }
.login-intro > p:last-child { max-width: 660px; color: var(--muted); font-size: 1.08rem; line-height: 1.7; }
.login-card { display: grid; gap: 20px; padding: clamp(25px, 4vw, 42px); border: 1px solid var(--line); border-top: 5px solid var(--accent); border-radius: 18px; background: #fff; box-shadow: 0 24px 60px rgba(21, 39, 36, 0.14); }
.login-card h2 { margin: 5px 0 0; font-family: Georgia, serif; font-size: 2.2rem; font-weight: 600; }
.login-submit { width: 100%; min-height: 49px; }
.login-help { margin: -4px 0 0; color: var(--muted); font-size: 0.82rem; text-align: center; }
.login-maintenance-banner { display: grid; gap: 5px; margin: 0 0 24px; padding: 16px 18px; border: 1px solid #d8b86f; border-left: 5px solid var(--accent); border-radius: 11px; background: #fff8e8; box-shadow: var(--shadow); }
.login-maintenance-banner[data-phase="active"] { border-color: #d29a70; border-left-color: #b85f2f; background: #fff4ec; }
.login-maintenance-banner > span { color: #8a5a16; font-size: 0.72rem; font-weight: 850; text-transform: uppercase; letter-spacing: 0.09em; }
.login-maintenance-banner > strong { font-size: 1.05rem; }
.login-maintenance-banner p { margin: 0; color: var(--muted); line-height: 1.45; }

.workspace-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 28px; margin-bottom: 35px; }
.workspace-hero h1 { margin: 5px 0 9px; font-family: Georgia, serif; font-size: clamp(2.5rem, 5vw, 5.2rem); line-height: 1; font-weight: 600; letter-spacing: -0.045em; }
.workspace-user { min-width: 230px; display: grid; gap: 4px; padding: 16px 19px; border-left: 4px solid var(--accent); background: #fff; box-shadow: var(--shadow); }
.workspace-user span { color: var(--muted); font-size: 0.78rem; }
.module-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.module-card { min-height: 260px; display: grid; grid-template-columns: 92px 1fr; grid-template-rows: 1fr auto; gap: 22px; padding: clamp(24px, 4vw, 42px); border: 1px solid var(--line); border-radius: 18px; color: var(--ink); background: #fff; box-shadow: var(--shadow); text-decoration: none; transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease; }
a.module-card:hover { transform: translateY(-4px); border-color: #87a69f; color: var(--ink); box-shadow: 0 22px 48px rgba(21, 39, 36, 0.14); }
.module-logo { width: 92px; height: 92px; display: grid; place-items: center; border-radius: 22px; background: var(--surface-soft); }
.module-logo img { width: 78px; height: 78px; }
.module-content { display: grid; align-content: start; gap: 11px; }
.module-content strong { font-family: Georgia, serif; font-size: clamp(1.7rem, 3vw, 2.45rem); line-height: 1.08; font-weight: 600; }
.module-content > span { max-width: 560px; color: var(--muted); line-height: 1.6; }
.module-status { grid-column: 2; align-self: end; color: var(--brand); font-weight: 800; }
.module-card-disabled { filter: grayscale(0.65); opacity: 0.58; box-shadow: none; }
.module-card-disabled .module-status { color: var(--muted); }
.quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; margin-top: 24px; }
.quick-card { display: grid; gap: 7px; padding: 22px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: #fff; box-shadow: var(--shadow); text-decoration: none; }
.quick-card:hover { color: var(--brand-dark); border-color: #87a69f; }
.quick-card strong { font-size: 1.05rem; }
.quick-card span { color: var(--muted); font-size: 0.87rem; line-height: 1.45; }

.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 9px; padding: 9px 15px; font-weight: 700; line-height: 1.2; text-decoration: none; cursor: pointer; transition: background 120ms ease, border-color 120ms ease, transform 120ms ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--brand); color: #fff; }
.button-primary:hover { color: #fff; background: var(--brand-dark); }
.button-secondary { background: #fff; color: var(--brand); border-color: #aebfbb; }
.button-secondary:hover { background: #edf4f2; }
.button-danger { background: #fff; color: var(--danger); border-color: #d8a7aa; }
.button-danger:hover { color: #fff; background: var(--danger-dark); border-color: var(--danger-dark); }
.button-small { min-height: 34px; padding: 6px 10px; font-size: 0.84rem; }
.text-link { font-weight: 650; }

.toolbar, .filter-card, .form-card, .table-card { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 15px; margin-bottom: 18px; }
.search-form, .toolbar-links, .form-actions, .row-actions { display: flex; align-items: center; gap: 9px; }
.search-form { flex: 1 1 520px; }
.search-form input { min-width: 220px; max-width: 500px; }
.toolbar-links { flex-wrap: wrap; justify-content: flex-end; }
.toolbar-links a { font-size: 0.91rem; font-weight: 700; }

.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 15px; border-bottom: 1px solid #dce5e2; text-align: left; vertical-align: middle; }
th { color: #405651; background: var(--surface-soft); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.055em; white-space: nowrap; }
tbody tr:hover { background: #f8fbfa; }
tbody tr:last-child td { border-bottom: 0; }
.actions-column { width: 190px; }
.row-actions { flex-wrap: nowrap; }
.row-actions form { margin: 0; }
.muted { display: block; color: var(--muted); font-size: 0.82rem; margin-top: 3px; }
.empty-state { padding: 38px; color: var(--muted); text-align: center; }
.narrow-card { max-width: 760px; }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; }
.access-badge { display: inline-flex; border-radius: 999px; padding: 5px 9px; color: #174b40; background: #e3f0ed; font-size: 0.76rem; font-weight: 750; }
.developer-badge { display: inline-flex; margin-left: 8px; border-radius: 999px; padding: 4px 8px; color: #593600; background: #f4d99f; font-size: 0.7rem; font-weight: 850; text-transform: uppercase; letter-spacing: 0.04em; }
.protected-label { color: var(--muted); font-size: 0.82rem; font-weight: 750; }
.status-pill { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-size: 0.76rem; font-weight: 800; }
.status-active { color: var(--success-ink); background: var(--success-bg); }
.status-disabled { color: var(--error-ink); background: var(--error-bg); }

.form-card, .filter-card { padding: 25px; }
.filter-card { margin-bottom: 20px; }
.form-grid { display: grid; gap: 20px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.four-columns { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 0.9rem; font-weight: 750; }
input, select { width: 100%; min-height: 43px; border: 1px solid #aebfbb; border-radius: 8px; padding: 9px 11px; color: var(--ink); background: #fff; }
input:hover, select:hover { border-color: #708984; }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31, 79, 70, 0.12); outline: none; }
input[type="file"] { padding: 8px; }
.field-hint { margin: 0; color: var(--muted); font-size: 0.82rem; }
.form-actions { margin-top: 24px; }
.access-fieldset { margin: 24px 0 0; padding: 0; border: 0; }
.access-fieldset legend { margin-bottom: 11px; font-size: 0.9rem; font-weight: 750; }
.access-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.access-option, .active-option { display: flex; align-items: flex-start; gap: 11px; padding: 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); cursor: pointer; }
.access-option input, .active-option input { flex: 0 0 auto; width: 19px; min-height: 19px; margin-top: 2px; accent-color: var(--brand); }
.access-option span, .active-option span { display: grid; gap: 4px; }
.access-option small, .active-option small { color: var(--muted); line-height: 1.4; }
.active-option { max-width: 520px; margin-top: 15px; background: #fff; }
.developer-notice { display: grid; gap: 5px; margin-bottom: 22px; padding: 15px 17px; border: 1px solid #d8b86f; border-left: 5px solid var(--accent); border-radius: 10px; color: #563b0d; background: #fff8e8; }
.developer-notice span { color: #725a2e; line-height: 1.45; }
.delete-user-summary { display: grid; gap: 4px; margin-bottom: 18px; padding: 16px; border-left: 5px solid var(--danger); border-radius: 9px; background: var(--error-bg); }
.delete-user-summary span, .delete-user-summary small { color: var(--muted); }
.delete-user-summary strong { font-size: 1.2rem; }
.three-metrics { grid-template-columns: repeat(3, minmax(0, 240px)); }
.maintenance-planner { display: grid; gap: 18px; }
.maintenance-planner-heading { display: flex; justify-content: space-between; align-items: end; gap: 28px; }
.maintenance-planner-heading h2 { margin: 5px 0 0; font-family: Georgia, serif; font-size: clamp(1.7rem, 3vw, 2.5rem); }
.maintenance-planner-heading > p { max-width: 500px; margin: 0; color: var(--muted); line-height: 1.5; }
.maintenance-form { margin: 0; }
.maintenance-preview { margin-top: 21px; padding: 15px 17px; border-left: 4px solid var(--accent); border-radius: 9px; background: var(--surface-soft); }
.maintenance-preview p { margin: 5px 0 0; color: var(--muted); line-height: 1.5; }
.maintenance-current { display: flex; justify-content: space-between; align-items: center; gap: 25px; padding: 24px; border: 1px solid #d8b86f; border-radius: 14px; background: #fffaf0; box-shadow: var(--shadow); }
.maintenance-current-status { display: grid; gap: 7px; }
.maintenance-current-status strong { font-size: 1.15rem; }
.maintenance-current-status small { color: var(--muted); }
.status-scheduled { color: #72500f; background: #f7e8bc; }
.deployment-panel { display: grid; gap: 18px; margin-top: 34px; }
.deployment-card { display: flex; justify-content: space-between; align-items: center; gap: 25px; padding: 24px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.deployment-status { display: grid; gap: 7px; min-width: 0; }
.deployment-status code { overflow-wrap: anywhere; }
.deployment-status small { color: var(--muted); }
.status-deployment-running, .status-deployment-queued { color: #72500f; background: #f7e8bc; }
.status-deployment-succeeded { color: var(--success-ink); background: var(--success-bg); }
.status-deployment-failed { color: var(--error-ink); background: var(--error-bg); }
.deployment-card .button:disabled { cursor: not-allowed; filter: grayscale(0.6); opacity: 0.55; transform: none; }

.maintenance-notice { position: fixed; z-index: 80; top: 94px; right: 18px; width: min(370px, calc(100vw - 36px)); padding: 17px 45px 17px 18px; border: 1px solid #d8b86f; border-left: 5px solid var(--accent); border-radius: 12px; color: var(--ink); background: rgba(255, 253, 247, 0.98); box-shadow: 0 14px 34px rgba(21, 39, 36, 0.15); }
.maintenance-notice[data-phase="active"] { border-color: #d29a70; border-left-color: #b85f2f; background: rgba(255, 249, 244, 0.98); }
.maintenance-notice-label { display: block; margin-bottom: 5px; color: #8a5a16; font-size: 0.68rem; font-weight: 850; text-transform: uppercase; letter-spacing: 0.09em; }
.maintenance-notice-title { display: block; padding-right: 4px; font-size: 1rem; }
.maintenance-notice-message { margin: 7px 0 0; color: var(--muted); font-size: 0.86rem; line-height: 1.5; }
.maintenance-notice-close { position: absolute; top: 8px; right: 8px; width: 32px; min-height: 32px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 1.35rem; line-height: 1; cursor: pointer; }
.maintenance-notice-close:hover { color: var(--ink); background: rgba(21, 39, 36, 0.07); }
.maintenance-notice[hidden], .server-connection-status[hidden] { display: none; }
.server-connection-status { position: fixed; z-index: 90; right: 18px; bottom: 18px; display: flex; align-items: center; gap: 10px; width: min(330px, calc(100vw - 36px)); padding: 12px 15px; border: 1px solid #d8b86f; border-radius: 11px; color: #5d430f; background: rgba(255, 250, 237, 0.98); box-shadow: 0 12px 30px rgba(21, 39, 36, 0.15); }
.server-connection-status[data-state="connected"] { color: var(--success-ink); border-color: #9ac8ad; background: rgba(238, 249, 242, 0.98); }
.server-connection-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(201, 140, 44, 0.14); }
.server-connection-status[data-state="connected"] .server-connection-dot { background: #2a8954; box-shadow: 0 0 0 4px rgba(42, 137, 84, 0.13); }
.server-connection-message { font-size: 0.88rem; }

.flash-stack { display: grid; gap: 8px; margin-bottom: 22px; }
.flash { border-radius: 9px; padding: 12px 14px; border: 1px solid transparent; }
.flash-success { background: var(--success-bg); color: var(--success-ink); border-color: #a9d6bb; }
.flash-error { background: var(--error-bg); color: var(--error-ink); border-color: #e1b6b8; }
.pagination { display: flex; justify-content: center; gap: 18px; align-items: center; margin-top: 20px; color: var(--muted); }
.pagination a { font-weight: 700; }
.metric-row { display: grid; grid-template-columns: repeat(2, minmax(0, 240px)); gap: 14px; margin: 20px 0; }
.metric { background: #173e37; color: #fff; border-radius: 14px; padding: 18px 20px; }
.metric span { display: block; color: #c9ddd8; font-size: 0.82rem; }
.metric strong { display: block; margin-top: 6px; font-family: Georgia, serif; font-size: 1.8rem; font-weight: 600; }
.error-page { max-width: 700px; padding: 70px 0; }
.error-page h1 { font-family: Georgia, serif; font-size: clamp(2rem, 5vw, 4rem); margin: 8px 0 14px; }
.error-page p:not(.eyebrow) { color: var(--muted); margin-bottom: 25px; }

@media (max-width: 1100px) {
    .header-inner { align-items: flex-start; flex-direction: column; gap: 8px; padding: 15px 0; }
    .user-area { position: absolute; top: 14px; right: 20px; }
    .three-columns, .four-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .login-layout { grid-template-columns: 1fr 410px; gap: 45px; }
    .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .shell { width: min(100% - 24px, 1440px); }
    .page-content { padding-top: 28px; }
    .page-heading, .toolbar { align-items: stretch; flex-direction: column; }
    .page-heading .button { width: 100%; }
    .primary-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
    .primary-nav > a, .nav-dropdown > summary { padding-left: 0; }
    .primary-nav > .developer-nav-link { margin-left: 0; padding-left: 11px; }
    .nav-dropdown-menu { position: static; min-width: 0; margin: 3px 0 8px; box-shadow: none; }
    .search-form { flex: 1 1 auto; flex-wrap: wrap; }
    .search-form input { max-width: none; min-width: 0; }
    .toolbar-links { justify-content: flex-start; }
    .two-columns, .three-columns, .four-columns { grid-template-columns: 1fr; }
    .form-card, .filter-card { padding: 18px; }
    .metric-row { grid-template-columns: 1fr 1fr; }
    .login-layout { min-height: auto; grid-template-columns: 1fr; gap: 28px; }
    .login-intro h1 { font-size: clamp(2.5rem, 12vw, 4.5rem); }
    .workspace-hero { align-items: stretch; flex-direction: column; }
    .workspace-user { min-width: 0; }
    .module-grid { grid-template-columns: 1fr; }
    .module-card { min-height: 220px; }
    .access-options { grid-template-columns: 1fr; }
    .user-area { position: static; width: 100%; justify-content: space-between; margin: 8px 0 0; padding: 10px 0 0; border-top: 1px solid rgba(255, 255, 255, 0.18); }
    .user-area > span { text-align: left; }
    .maintenance-planner-heading, .maintenance-current, .deployment-card { align-items: stretch; flex-direction: column; }
    .maintenance-current .button, .deployment-card .button { width: 100%; }
    .maintenance-notice { top: auto; right: 12px; bottom: 12px; width: calc(100vw - 24px); }
    .server-connection-status { right: 12px; bottom: 12px; width: calc(100vw - 24px); }
    .server-connection-visible .maintenance-notice { bottom: 76px; }
    th, td { padding: 12px; }
}

@media (max-width: 460px) {
    .primary-nav { grid-template-columns: 1fr; }
    .row-actions { align-items: stretch; flex-direction: column; }
    .row-actions .button { width: 100%; }
    .metric-row { grid-template-columns: 1fr; }
    .module-card { grid-template-columns: 68px 1fr; gap: 15px; padding: 21px; }
    .module-logo { width: 68px; height: 68px; border-radius: 17px; }
    .module-logo img { width: 58px; height: 58px; }
    .quick-grid { grid-template-columns: 1fr; }
}
