:root {
    color-scheme: light;
    --bg: #eef4f6;
    --surface: #ffffff;
    --ink: #17211f;
    --muted: #65736f;
    --line: #dbe2df;
    --accent: #146c64;
    --accent-strong: #0f514b;
    --nav: #073647;
    --nav-panel: #123f51;
    --nav-panel-deep: #0d2f3d;
    --danger: #a23434;
    --success: #146c43;
    --focus: #b06f1f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
}

.app-shell {
    display: grid;
    min-height: 100vh;
}

.workspace {
    min-width: 0;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(140deg, rgb(7 54 71 / 92%), rgb(16 104 98 / 82%)),
        radial-gradient(circle at 20% 20%, #ccefe8, transparent 32%);
}

.login-panel {
    display: grid;
    gap: 18px;
    width: min(460px, 100%);
    border: 1px solid rgb(255 255 255 / 16%);
    border-radius: 8px;
    background: rgb(255 255 255 / 96%);
    padding: 30px;
    box-shadow: 0 22px 70px rgb(0 0 0 / 24%);
}

.login-brand {
    display: grid;
    gap: 2px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 18px;
}

.login-brand h1 {
    font-size: 34px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 28px clamp(18px, 4vw, 48px);
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    min-height: 40px;
    gap: 10px;
    padding: 0 14px;
    background: var(--nav);
    color: #fff;
    box-shadow: 0 1px 0 rgb(255 255 255 / 10%);
}

.app-logo {
    color: #fff;
    font-size: 20px;
    font-weight: 850;
    letter-spacing: 0;
    text-decoration: none;
    white-space: nowrap;
}

.app-logo span {
    color: #7ed877;
}

.tab-nav {
    display: flex;
    align-items: stretch;
    gap: 2px;
    min-height: 40px;
}

.top-menu,
.user-menu {
    position: relative;
}

.top-menu > summary,
.user-menu > summary {
    display: flex;
    align-items: center;
    min-height: 40px;
    border: 1px solid transparent;
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    color: #fff;
    cursor: pointer;
    font-weight: 750;
    list-style: none;
    padding: 0 11px;
    font-size: 13px;
}

.top-menu > summary::-webkit-details-marker,
.user-menu > summary::-webkit-details-marker {
    display: none;
}

.top-menu[open] > summary {
    background: var(--nav-panel-deep);
    border-color: rgb(255 255 255 / 22%);
}

.dropdown-panel,
.account-panel {
    position: absolute;
    top: 40px;
    z-index: 30;
    border: 1px solid rgb(152 190 203 / 42%);
    border-radius: 0 8px 8px;
    background: var(--nav-panel);
    box-shadow: 0 14px 28px rgb(0 0 0 / 24%);
}

.all-panel {
    left: 0;
    display: grid;
    gap: 12px;
    width: min(360px, calc(100vw - 24px));
    max-height: calc(100vh - 70px);
    overflow: auto;
    padding: 12px;
}

.history-panel {
    left: 0;
    display: grid;
    gap: 4px;
    width: min(320px, calc(100vw - 24px));
    padding: 10px;
}

.history-panel a,
.account-panel a {
    border-radius: 6px;
    color: #e8f3f5;
    font-weight: 700;
    padding: 10px 11px;
    text-decoration: none;
}

.history-panel a:hover,
.account-panel a:hover {
    background: rgb(255 255 255 / 10%);
}

.filter-row {
    display: grid;
    grid-template-columns: 26px 1fr;
    align-items: center;
    border-radius: 4px;
    background: #6c8592;
    color: #fff;
    padding: 0 8px;
}

.filter-row input {
    min-height: 31px;
    border: 0;
    background: transparent;
    color: #fff;
    font-weight: 750;
    padding: 5px;
}

.filter-row input::placeholder {
    color: #fff;
}

.filter-row input:focus {
    outline: 0;
}

.filter-icon {
    color: #fff;
    font-size: 18px;
}

.menu-tree {
    display: grid;
    gap: 2px;
}

.search-results {
    display: grid;
    gap: 2px;
    border-bottom: 1px solid rgb(198 216 212 / 20%);
    padding-bottom: 10px;
}

.search-results p {
    color: #9db8c2;
    font-size: 12px;
    font-weight: 800;
    padding: 2px 10px 5px;
    text-transform: uppercase;
}

.search-results a,
.search-results span {
    border-radius: 5px;
    color: #f4fbfc;
    font-weight: 760;
    padding: 8px 10px;
    text-decoration: none;
}

.search-results a:hover {
    background: rgb(255 255 255 / 10%);
}

.search-results span {
    color: #cfe2e6;
}

.menu-tree a,
.menu-tree summary {
    border-radius: 5px;
    color: #e8f3f5;
    cursor: pointer;
    font-weight: 760;
    list-style: none;
    padding: 8px 10px;
    text-decoration: none;
}

.menu-tree details {
    display: grid;
    gap: 2px;
}

.menu-tree summary::-webkit-details-marker {
    display: none;
}

.menu-tree summary::before {
    content: "›";
    display: inline-block;
    margin-right: 9px;
    transform: rotate(90deg);
}

.menu-tree details:not([open]) summary::before {
    transform: none;
}

.menu-tree details[open] > summary {
    background: var(--nav-panel-deep);
}

.tree-children {
    display: grid;
    gap: 2px;
    margin-left: 21px;
    border-left: 1px solid rgb(198 216 212 / 48%);
    padding-left: 14px;
}

.menu-tree details a {
    border-radius: 0 5px 5px 0;
    color: #cfe2e6;
    font-weight: 650;
}

.menu-tree .tree-root:hover,
.menu-tree summary:hover,
.menu-tree details a:hover {
    background: rgb(255 255 255 / 10%);
}

.user-menu {
    margin-left: auto;
}

.user-menu > summary {
    border-radius: 7px;
    min-height: 30px;
    font-size: 13px;
}

.user-menu[open] > summary {
    background: rgb(255 255 255 / 12%);
}

.account-panel {
    right: 0;
    left: auto;
    top: 36px;
    width: 170px;
    border-radius: 8px 0 8px 8px;
    padding: 7px;
}

.empty-panel {
    color: #cfe2e6;
    padding: 8px;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: clamp(28px, 4vw, 42px);
    font-weight: 750;
}

h2 {
    font-size: 20px;
}

.eyebrow {
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.layout {
    display: grid;
    gap: 18px;
    padding: 28px clamp(18px, 4vw, 48px) 48px;
}

.muted {
    color: var(--muted);
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 2px rgb(23 33 31 / 4%);
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.section-title span {
    color: var(--muted);
    font-size: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.record-form {
    display: grid;
    gap: 12px;
}

.record-actionbar {
    position: sticky;
    top: 40px;
    z-index: 18;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: -20px -20px 8px;
    border-bottom: 1px solid var(--line);
    border-radius: 8px 8px 0 0;
    background: #fbfcfc;
    padding: 8px 12px 8px 18px;
}

.record-title {
    display: grid;
    gap: 3px;
}

.record-title strong {
    color: var(--ink);
    font-size: 18px;
    line-height: 1;
}

.record-title span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.record-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.small-action {
    min-height: 42px;
    padding: 10px 16px;
}

.record-header-grid {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
    gap: 8px 32px;
}

.record-column {
    display: grid;
    align-content: start;
    gap: 8px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

label.required {
    position: relative;
}

label.required::before {
    content: "*";
    position: absolute;
    left: -12px;
    top: 7px;
    color: var(--ink);
    font-size: 20px;
    font-weight: 500;
}

.record-form label {
    grid-template-columns: 132px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
}

.record-form label.wide {
    grid-column: 1 / -1;
}

.record-form label > input,
.record-form label > select,
.record-form label > textarea,
.record-form label > .lookup-row,
.record-form label > .lookup-with-actions,
.record-form label > .compact-control {
    grid-column: 2;
}

.record-form label > textarea {
    align-self: stretch;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    padding: 10px 11px;
}

textarea {
    resize: vertical;
}

input:disabled {
    background: #eef2f0;
    color: #66736f;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--focus);
    outline: 3px solid rgb(176 111 31 / 18%);
}

.lookup-field {
    min-width: min(100%, 360px);
}

.lookup-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) 34px;
    gap: 0;
    align-items: center;
}

.lookup-with-actions {
    display: grid;
    grid-template-columns: minmax(180px, calc(100% - 80px)) 34px 34px;
    gap: 6px;
    align-items: center;
}

.lookup-row select {
    min-height: 34px;
    border-color: #9db9c5;
    border-radius: 3px 0 0 3px;
    padding: 5px 9px;
}

.lookup-button {
    display: grid;
    width: 34px;
    min-height: 34px;
    place-items: center;
    border: 1px solid #9db9c5;
    border-left: 0;
    border-radius: 0 5px 5px 0;
    background: #fff;
    color: #00729b;
    cursor: pointer;
    font: inherit;
    font-size: 17px;
    font-weight: 800;
    line-height: 1;
    padding: 0;
}

.lookup-button:hover {
    background: #eaf6fa;
}

.compact-control {
    display: block;
    width: calc(100% - 80px);
}

.compact-control select {
    width: 100%;
}

.icon-button {
    display: grid;
    width: 34px;
    min-height: 34px;
    place-items: center;
    border: 1px solid #a8bfca;
    border-radius: 6px;
    background: #fff;
    color: #00729b;
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
    padding: 0;
}

.icon-button:hover {
    background: #eaf6fa;
}

.lookup-modal {
    width: min(840px, calc(100vw - 40px));
    border: 1px solid #9eb8c4;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 22px 70px rgb(0 0 0 / 28%);
}

.lookup-modal::backdrop {
    background: rgb(10 32 40 / 36%);
}

.lookup-modal-window {
    display: grid;
    max-height: min(620px, calc(100vh - 60px));
    background: #fff;
}

.lookup-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    background: #eef6f8;
    padding: 12px 14px;
}

.lookup-modal-filter {
    border-bottom: 1px solid var(--line);
    padding: 10px 14px;
}

.lookup-modal-filter label {
    display: grid;
    grid-template-columns: 72px minmax(200px, 320px);
    align-items: center;
    gap: 10px;
}

.lookup-table-wrap {
    overflow: auto;
}

.lookup-table {
    min-width: 720px;
}

.lookup-table th {
    background: #e1f1f5;
}

.lookup-table tbody tr:nth-child(even) {
    background: #f4f8f9;
}

.lookup-user-choice {
    width: auto;
    min-height: auto;
    border: 0;
    background: transparent;
    color: #006d91;
    cursor: pointer;
    font: inherit;
    font-weight: 750;
    padding: 0;
    text-align: left;
}

.lookup-user-choice:hover {
    color: #004f69;
    text-decoration: underline;
}

.user-overview {
    padding-top: 8px;
}

.user-overview dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 10px 28px;
    margin: 0;
}

.user-overview div {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
}

.user-overview dt {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-align: right;
}

.user-overview dd {
    min-height: 34px;
    margin: 0;
    border: 1px solid #a7bdc8;
    border-radius: 3px;
    background: #fff;
    color: var(--ink);
    padding: 7px 9px;
}

.user-edit-grid {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
    gap: 8px 42px;
    padding-top: 8px;
}

.user-record-form label {
    grid-template-columns: 150px minmax(0, 1fr);
}

.user-record-form .inline-checkbox {
    grid-template-columns: 150px 18px minmax(0, 1fr);
    min-height: 34px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.user-record-form .inline-checkbox span {
    grid-column: 1;
    justify-self: end;
}

.user-record-form .inline-checkbox input {
    grid-column: 2;
}

.checkbox-control {
    display: flex;
    align-items: center;
    min-height: 34px;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-height: 16px;
    accent-color: var(--accent);
    padding: 0;
}

.password-modal {
    width: min(460px, calc(100vw - 40px));
}

.password-fields {
    display: grid;
    gap: 12px;
    padding: 14px;
}

.password-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--line);
    padding: 12px 14px;
}

.related-tabs {
    margin: 22px -20px -20px;
    border-top: 1px solid var(--line);
}

.related-tabbar {
    display: flex;
    align-items: end;
    min-height: 36px;
    border-bottom: 1px solid #b8c9d0;
    background: #edf4f5;
    padding-left: 0;
}

.related-tab {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    border: 1px solid #b8c9d0;
    border-bottom: 0;
    border-radius: 0;
    background: #dce8eb;
    color: var(--ink);
    font-weight: 650;
    padding: 8px 12px;
    text-decoration: none;
}

.related-tab.active {
    border-top: 3px solid #2b8a38;
    background: #fff;
    color: #1b6f2b;
}

.related-panel {
    background: #fff;
}

.related-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    background: #e7f0f2;
    padding: 8px 12px;
}

.related-toolbar .button-link {
    margin-left: auto;
}

.filter-row.light {
    width: min(290px, 100%);
    border-color: #9db9c5;
    background: #fff;
}

.filter-row.light input,
.filter-row.light .filter-icon {
    color: var(--ink);
}

.filter-row.light input::placeholder {
    color: var(--muted);
}

.role-editor {
    display: grid;
    gap: 8px;
    max-width: 760px;
    padding: 2px 36px 10px;
}

.dual-list {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 42px minmax(240px, 1fr);
    gap: 14px;
    align-items: end;
}

.dual-list section {
    display: grid;
    gap: 8px;
}

.dual-list h3,
.dual-list p {
    margin: 0;
    color: var(--ink);
    font-size: 14px;
    font-weight: 650;
}

.dual-list select {
    height: 300px;
    border-color: #9db9c5;
    border-radius: 3px;
    background: #fff;
    padding: 6px;
}

.dual-actions {
    display: grid;
    gap: 8px;
    justify-content: center;
    padding-bottom: 116px;
}

.dual-search {
    position: relative;
    display: block;
}

.dual-search .filter-icon {
    position: absolute;
    left: 10px;
    top: 8px;
    color: #00729b;
}

.dual-search input {
    min-height: 32px;
    padding-left: 34px;
}

.role-editor-footer {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 0;
}

.wide {
    grid-column: 1 / -1;
}

.checkbox {
    align-content: end;
    grid-template-columns: 18px 1fr;
    gap: 10px;
    min-height: 42px;
    color: var(--ink);
}

.checkbox input {
    min-height: auto;
    margin-top: 3px;
}

button,
.button-link {
    align-self: end;
    width: fit-content;
    min-height: 42px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    padding: 10px 16px;
    text-decoration: none;
}

.record-form input,
.record-form select {
    min-height: 34px;
    border-color: #a7bdc8;
    border-radius: 3px;
    padding: 6px 9px;
}

.record-form textarea {
    border-color: #a7bdc8;
    border-radius: 3px;
    padding: 8px 9px;
}

button:hover,
.button-link:hover {
    background: var(--accent-strong);
}

button.icon-button {
    align-self: center;
    width: 34px;
    min-height: 34px;
    border: 1px solid #a8bfca;
    border-radius: 6px;
    background: #fff;
    color: #00729b;
    font-size: 16px;
    font-weight: 800;
    padding: 0;
}

button.icon-button:hover {
    background: #eaf6fa;
}

button.lookup-button {
    align-self: center;
    width: 34px;
    min-height: 34px;
    border: 1px solid #9db9c5;
    border-left: 0;
    border-radius: 0 5px 5px 0;
    background: #fff;
    color: #00729b;
    padding: 0;
}

button.lookup-button:hover {
    background: #eaf6fa;
}

.related-tabbar .related-tab {
    align-self: stretch;
    width: auto;
    min-height: 36px;
    border: 1px solid #b8c9d0;
    border-bottom: 0;
    border-radius: 0;
    background: #dce8eb;
    color: var(--ink);
    font-weight: 650;
    padding: 8px 12px;
    text-decoration: none;
}

.related-tabbar .related-tab.active {
    border-top: 3px solid #2b8a38;
    background: #fff;
    color: #1b6f2b;
}

.button-link.subtle {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
}

.button-link.subtle:hover {
    background: #eef2f0;
}

.role-switch {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.role-switch a {
    color: var(--ink);
    padding: 9px 13px;
    text-decoration: none;
}

.role-switch a.active {
    background: var(--accent);
    color: #fff;
}

.message {
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 700;
}

.message.error {
    background: #fff0f0;
    color: var(--danger);
    border: 1px solid #efcccc;
}

.message.success {
    background: #eef9f3;
    color: var(--success);
    border: 1px solid #c7ead7;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 11px 10px;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

td a {
    color: var(--accent);
    font-weight: 800;
    text-decoration: none;
}

.empty {
    color: var(--muted);
    text-align: center;
}

.detail {
    border-color: #b8c9c5;
}

.activity-log {
    display: grid;
    gap: 12px;
    margin-top: 22px;
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.activity-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.activity-log h3 {
    margin: 0;
    font-size: 17px;
}

.log-entry {
    display: grid;
    gap: 8px;
    border: 1px solid var(--line);
    border-left: 4px solid #d6e2e6;
    border-radius: 4px;
    background: #fbfdfd;
    padding: 13px 14px;
    box-shadow: 0 2px 5px rgb(23 33 31 / 10%);
}

.log-entry.work-note-entry {
    border-left-color: #ffd92f;
}

.log-meta {
    display: grid;
    grid-template-columns: 28px auto 1fr;
    align-items: center;
    gap: 8px;
}

.avatar {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    border-radius: 999px;
    background: #edf5f7;
    color: #315262;
    font-size: 11px;
    font-weight: 800;
}

.log-type {
    justify-self: end;
    color: #2f4856;
    font-size: 13px;
}

.empty-log {
    color: var(--muted);
    font-size: 13px;
}

.log-entry p {
    line-height: 1.5;
}

.field-change-list {
    display: grid;
    gap: 8px;
    margin: 8px 0 0 72px;
}

.field-change-list div {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 18px;
}

.field-change-list dt {
    color: #29424d;
    font-weight: 800;
    text-align: right;
}

.field-change-list dd {
    margin: 0;
}

.field-change-list span {
    color: var(--muted);
    margin: 0 6px;
}

.install {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.install .panel {
    width: min(520px, 100%);
}

.install h1 {
    margin-bottom: 16px;
}

@media (max-width: 720px) {
    .app-topbar {
        align-items: flex-start;
        flex-wrap: wrap;
        min-height: auto;
        padding: 10px 12px;
    }

    .tab-nav {
        order: 3;
        width: 100%;
        min-height: 42px;
    }

    .top-menu > summary {
        min-height: 38px;
    }

    .dropdown-panel {
        top: 38px;
    }

    .user-menu {
        margin-left: auto;
    }

    .record-actionbar {
        top: 88px;
    }

    .record-header-grid {
        grid-template-columns: 1fr;
    }

    .user-edit-grid {
        grid-template-columns: 1fr;
    }

    .user-overview dl {
        grid-template-columns: 1fr;
    }

    .user-overview div {
        grid-template-columns: 1fr;
    }

    .user-overview dt {
        text-align: left;
    }

    .dual-list {
        grid-template-columns: 1fr;
    }

    .dual-actions {
        grid-template-columns: repeat(2, 34px);
    }
}
