:root {
    color-scheme: light;
    --ink: #18202a;
    --muted: #5d6875;
    --line: #d9e0e7;
    --panel: #ffffff;
    --soft: #f4f7f9;
    --accent: #0f766e;
    --accent-strong: #0b5f59;
    --warn: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.14), rgba(30, 64, 175, 0.08)),
        var(--soft);
}

.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 460px);
}

.brand-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(32px, 6vw, 80px);
    background:
        linear-gradient(rgba(11, 31, 42, 0.76), rgba(11, 31, 42, 0.76)),
        url("https://images.unsplash.com/photo-1503387762-592deb58ef4e?auto=format&fit=crop&w=1600&q=80");
    background-size: cover;
    background-position: center;
    color: white;
}

.brand-panel h1 {
    max-width: 680px;
    margin: 12px 0 18px;
    font-size: clamp(2.4rem, 5vw, 5rem);
    line-height: 1;
    letter-spacing: 0;
}

.summary {
    max-width: 560px;
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 1.08rem;
    line-height: 1.6;
}

.eyebrow {
    margin: 0;
    color: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 190px));
    gap: 14px;
    margin: 48px 0 0;
}

.status-grid div {
    border: 1px solid rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.08);
    padding: 16px;
    border-radius: 8px;
}

.status-grid dt {
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.78rem;
}

.status-grid dd {
    margin: 6px 0 0;
    font-weight: 700;
}

.login-panel {
    display: grid;
    align-items: center;
    padding: 28px;
}

.login-form {
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 20px 70px rgba(24, 32, 42, 0.12);
}

.login-form h2 {
    margin: 8px 0 26px;
    font-size: 1.9rem;
    letter-spacing: 0;
}

label {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 700;
}

.required-mark {
    color: var(--warn);
}

input {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 13px;
    color: var(--ink);
    font: inherit;
}

input:focus {
    outline: 3px solid rgba(15, 118, 110, 0.18);
    border-color: var(--accent);
}

.password-field {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field input {
    padding-right: 48px;
}

.icon-button {
    position: absolute;
    top: 6px;
    right: 6px;
    display: grid;
    place-items: center;
    width: 34px;
    min-height: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    transform: none;
}

.icon-button:hover {
    background: var(--soft);
    color: var(--ink);
}

.icon-button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

button {
    width: 100%;
    min-height: 46px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: white;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

button:hover {
    background: var(--accent-strong);
}

.secondary-button {
    min-height: 40px;
    margin-top: 12px;
    border: 1px solid var(--line);
    background: white;
    color: var(--ink);
}

.secondary-button:hover {
    background: var(--soft);
}

button:disabled {
    cursor: wait;
    opacity: 0.7;
}

.message {
    min-height: 22px;
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.4;
}

.message.error {
    color: var(--warn);
}

.session-panel {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.session-panel dl {
    display: grid;
    gap: 12px;
    margin: 14px 0 0;
}

.session-panel div {
    display: grid;
    gap: 4px;
}

.session-panel dt {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.session-panel dd {
    margin: 0;
    overflow-wrap: anywhere;
}

@media (max-width: 820px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .brand-panel {
        min-height: 42vh;
    }

    .brand-panel h1 {
        font-size: 2.6rem;
    }
}

.app-body {
    background: var(--soft);
}

[hidden] {
    display: none !important;
}

.admin-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
}

.app-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 16px;
    border-right: 1px solid var(--line);
    background: white;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 100%;
}

.sidebar-link {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 0 10px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 700;
    text-decoration: none;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: var(--soft);
    color: var(--accent);
}

.sidebar-link-bottom {
    margin-top: auto;
}

.app-content {
    min-width: 0;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 24px clamp(18px, 4vw, 48px);
    border-bottom: 1px solid var(--line);
    background: white;
}

.app-header h1 {
    margin: 6px 0 0;
    font-size: 2rem;
    letter-spacing: 0;
}

.app-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-actions .helper-text {
    white-space: nowrap;
}

.app-actions .secondary-button {
    width: auto;
    min-width: 110px;
    margin-top: 0;
    padding: 0 16px;
    white-space: nowrap;
}

.text-link {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

.app-main {
    display: grid;
    gap: 20px;
    width: min(1120px, calc(100% - 36px));
    margin: 24px auto;
    min-width: 0;
}

.wide-main {
    width: min(1480px, calc(100% - 36px));
}

.workspace-panel {
    min-width: 0;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.panel-heading h2 {
    margin: 6px 0 0;
    font-size: 1.35rem;
    letter-spacing: 0;
}

.helper-text {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.context-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.context-button {
    width: auto;
    min-width: 150px;
    margin-top: 0;
    padding: 0 16px;
}

.context-button.active {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(160px, 280px) 140px;
    align-items: end;
    gap: 14px;
}

.inline-form label {
    margin-bottom: 0;
}

.user-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
    gap: 14px;
}

.user-form label {
    margin-bottom: 0;
}

.company-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
    gap: 14px;
}

.company-form label {
    margin-bottom: 0;
}

.stacked-form {
    display: grid;
    gap: 18px;
}

fieldset {
    min-width: 0;
    margin: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

legend {
    padding: 0 6px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.form-actions button {
    width: auto;
    min-width: 180px;
    padding: 0 18px;
}

select {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 13px;
    color: var(--ink);
    background: white;
    font: inherit;
}

select:focus {
    outline: 3px solid rgba(15, 118, 110, 0.18);
    border-color: var(--accent);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
}

.checkbox-label input {
    width: 18px;
    min-height: 18px;
}

.wide-field {
    grid-column: span 2;
}

.compact-button {
    width: auto;
    min-width: 110px;
    margin-top: 0;
    padding: 0 16px;
}

.row-actions {
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
}

.row-menu {
    position: relative;
    z-index: 2;
}

.icon-menu-button {
    display: grid;
    place-items: center;
    width: 36px;
    min-width: 36px;
    min-height: 36px;
    margin-top: 0;
    padding: 0;
    font-size: 1.2rem;
    line-height: 1;
}

.row-menu-panel {
    position: absolute;
    display: grid;
    gap: 4px;
    z-index: 9999;
    top: calc(100% + 4px);
    left: 0;
    min-width: 120px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    box-shadow: 0 14px 34px rgba(24, 32, 42, 0.12);
}

.read-table tr.menu-open-row {
    position: relative;
    z-index: 500;
}

.read-table tr.menu-open-row td {
    position: relative;
    z-index: 501;
}

.read-table tr.menu-open-row td.row-actions {
    z-index: 10000;
}

.row-menu-panel button {
    width: 100%;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 6px;
    background: white;
    color: var(--ink);
    text-align: left;
}

.row-menu-panel button:hover {
    background: var(--soft);
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 0;
}

.details-grid div {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
}

.details-grid dt {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.details-grid dd {
    margin: 6px 0 0;
    overflow-wrap: anywhere;
}

.table-wrap {
    max-width: 100%;
    overflow-x: auto;
}

.read-table-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
}

.directory-table-wrap {
    min-height: 456px;
}

.read-table {
    min-width: 2200px;
}

.users-read-table {
    min-width: 1200px;
}

.projects-read-table {
    width: 100%;
    min-width: 960px;
    table-layout: fixed;
}

.projects-read-table th:nth-child(1),
.projects-read-table td:nth-child(1) {
    width: 76px;
}

.projects-read-table th:nth-child(2),
.projects-read-table td:nth-child(2) {
    width: 17%;
}

.projects-read-table th:nth-child(3),
.projects-read-table td:nth-child(3) {
    width: 22%;
}

.projects-read-table th:nth-child(4),
.projects-read-table td:nth-child(4) {
    width: 120px;
}

.projects-read-table th:nth-child(5),
.projects-read-table td:nth-child(5) {
    width: 120px;
}

.projects-read-table th:nth-child(6),
.projects-read-table td:nth-child(6) {
    width: 18%;
}

.projects-read-table th:nth-child(7),
.projects-read-table td:nth-child(7) {
    width: 18%;
}

.projects-read-table th:nth-child(8),
.projects-read-table td:nth-child(8) {
    width: 110px;
}

.section-rows-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.section-panel .read-table-wrap {
    margin: 0 16px;
    border-radius: 6px;
    overflow: visible;
}

.section-rows-table th {
    background: var(--accent-strong);
    color: white;
    font-size: 0.74rem;
}

.section-rows-table td {
    background: white;
}

.section-rows-table th:nth-child(1),
.section-rows-table td:nth-child(1) {
    width: 56px;
}

.section-rows-table th:nth-child(2),
.section-rows-table td:nth-child(2) {
    width: 34%;
}

.section-rows-table th:nth-child(3),
.section-rows-table td:nth-child(3) {
    width: auto;
}

.section-rows-table th:nth-child(4),
.section-rows-table td:nth-child(4) {
    width: 120px;
}

.read-table th,
.read-table td {
    white-space: nowrap;
}

.read-table td {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.read-table td.row-actions {
    overflow: visible;
}

.read-table .row-actions {
    min-width: 150px;
    z-index: 30;
}

.read-table.section-rows-table .row-actions {
    width: 56px;
    min-width: 56px;
    max-width: 56px;
}

.read-table.section-rows-table .icon-menu-button {
    width: 32px;
    min-width: 32px;
    min-height: 32px;
    font-size: 1rem;
}

.read-table .compact-button {
    min-width: 88px;
    min-height: 36px;
    padding: 0 12px;
}

.status-button.is-enabled {
    border-color: #86efac;
    background: #dcfce7;
    color: #166534;
}

.status-button.is-enabled:hover {
    background: #bbf7d0;
}

.status-button.is-disabled {
    border-color: #fecaca;
    background: #fee2e2;
    color: #991b1b;
}

.status-button.is-disabled:hover {
    background: #fecaca;
}

.status-row-enabled {
    background: #f0fdf4;
}

.status-row-disabled {
    background: #fef2f2;
}

.status-row-enabled:hover {
    background: #dcfce7;
}

.status-row-disabled:hover {
    background: #fee2e2;
}

.clickable-row {
    cursor: pointer;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.module-card {
    display: grid;
    gap: 8px;
    min-height: 126px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    text-decoration: none;
    background: #fff;
}

.module-card:hover {
    border-color: var(--accent);
    box-shadow: 0 14px 34px rgba(24, 32, 42, 0.08);
}

.module-card span {
    font-size: 1.18rem;
    font-weight: 700;
}

.module-card small {
    color: var(--muted);
    line-height: 1.5;
}

.project-builder {
    display: grid;
    gap: 18px;
}

.project-read-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
    gap: 20px;
}

.project-builder-actions {
    display: flex;
    justify-content: flex-start;
}

.section-list {
    display: grid;
    gap: 18px;
}

.section-panel {
    display: grid;
    gap: 12px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    overflow: visible;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.section-panel-heading {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
    background: var(--soft);
}

.section-panel-heading.menu-open-row {
    z-index: 10000;
}

.section-heading-title {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
}

.section-heading-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-heading-actions .section-menu-panel {
    right: 0;
    left: auto;
}

.section-panel-heading h3 {
    margin: 0;
    color: #0f172a;
    font-size: 1rem;
}

.section-panel-heading strong {
    padding: 6px 10px;
    border-radius: 6px;
    background: white;
    color: var(--ink);
    font-size: 1rem;
}

.section-row-form {
    grid-template-columns: minmax(140px, 1fr) minmax(160px, 1.5fr) minmax(110px, 0.7fr) auto auto;
    padding: 0 16px 16px;
}

.project-summary-panel {
    position: sticky;
    top: 18px;
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.project-summary-panel h3 {
    margin: 0 0 14px;
    font-size: 1rem;
}

.project-summary-grid {
    grid-template-columns: 1fr;
    gap: 10px;
}

.app-modal {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.42);
}

.app-modal-panel {
    width: min(460px, 100%);
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}

.app-modal-panel .panel-heading {
    margin-bottom: 16px;
    padding: 0;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

@media (max-width: 760px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: static;
        height: auto;
        padding: 18px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .sidebar-nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        min-height: auto;
    }

    .sidebar-link {
        justify-content: center;
        text-align: center;
    }

    .sidebar-link-bottom {
        margin-top: 0;
    }

    .app-header,
    .panel-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .app-actions,
    .inline-form,
    .user-form,
    .company-form,
    .module-grid {
        grid-template-columns: 1fr;
    }

    .wide-field {
        grid-column: span 1;
    }

    .compact-button {
        width: 100%;
    }

    .details-grid {
        grid-template-columns: 1fr;
    }

    .project-read-layout {
        grid-template-columns: 1fr;
    }

    .project-summary-panel {
        position: static;
    }
}
