:root {
    color: #1d2129;
    background: #f4f5f7;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    letter-spacing: 0;
    --green: #17785b;
    --green-dark: #105d46;
    --red: #b42318;
    --line: #e1e4e8;
    --muted: #667085;
    --surface: #ffffff;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f4f5f7; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(380px, 100%); padding: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; color: #fff; background: var(--green); border-radius: 8px; font-weight: 700; }
.login-panel h1 { margin: 18px 0 24px; font-size: 24px; }
label { display: grid; gap: 7px; margin-bottom: 16px; color: #344054; font-size: 14px; font-weight: 600; }
input, select, textarea { width: 100%; min-height: 40px; border: 1px solid #cfd4dc; border-radius: 6px; padding: 9px 11px; color: #1d2129; background: #fff; outline: none; }
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 120, 91, .12); }
.form-error { color: var(--red); margin: 14px 0 0; font-size: 14px; }

.primary-button, .secondary-button, .danger-button { min-height: 38px; padding: 8px 14px; border-radius: 6px; border: 1px solid transparent; font-weight: 600; }
.primary-button { color: #fff; background: var(--green); }
.primary-button:hover { background: var(--green-dark); }
.secondary-button { color: #344054; background: #fff; border-color: #cfd4dc; }
.danger-button { color: var(--red); background: #fff; border-color: #f0b7b2; }
.icon-button { width: 38px; height: 38px; display: inline-grid; place-items: center; padding: 0; color: #475467; background: #fff; border: 1px solid #d7dbe1; border-radius: 6px; }
.icon-button svg { width: 18px; height: 18px; }
.icon-button:hover { color: var(--green); border-color: #8ab7a9; }

.app-shell { min-height: 100vh; }
.topbar { height: 64px; display: grid; grid-template-columns: 220px minmax(240px, 1fr) 40px; gap: 16px; align-items: center; padding: 0 24px; color: #fff; background: #202623; }
.brand { color: #fff; text-decoration: none; font-size: 17px; font-weight: 700; }
.organization-picker { display: flex; justify-content: flex-end; gap: 8px; }
.organization-picker select { width: min(360px, 100%); min-height: 38px; border-color: #4d5853; color: #fff; background: #303934; }
.topbar .icon-button { color: #e5e9e7; background: #303934; border-color: #4d5853; }

.workspace { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.section-nav { padding: 20px 12px; background: #fff; border-right: 1px solid var(--line); }
.nav-item { width: 100%; height: 42px; display: flex; align-items: center; gap: 10px; margin-bottom: 4px; padding: 0 12px; color: #475467; background: transparent; border: 0; border-radius: 6px; text-align: left; }
.nav-item svg { width: 18px; height: 18px; }
.nav-item:hover { background: #f2f4f5; }
.nav-item.active { color: var(--green-dark); background: #e9f3ef; font-weight: 700; }
.content { min-width: 0; padding: 28px; }
.page-view { max-width: 1280px; margin: 0 auto; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-header h1 { margin: 0 0 5px; font-size: 24px; }
.page-header p { margin: 0; color: var(--muted); }
.metric-row { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 1px; overflow: hidden; margin-bottom: 22px; border: 1px solid var(--line); border-radius: 7px; background: var(--line); }
.metric { min-height: 112px; padding: 20px; background: #fff; }
.metric span { display: block; color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 10px; font-size: 27px; }
.notice-band { padding: 16px 18px; border-left: 3px solid var(--green); background: #fff; color: #344054; }

.table-shell { overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.table-toolbar input { width: min(320px, 100%); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 13px 16px; border-bottom: 1px solid #eceef1; text-align: left; vertical-align: middle; }
.data-table th { color: #667085; background: #fafafa; font-size: 13px; font-weight: 700; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td.actions { width: 1%; white-space: nowrap; text-align: right; }
.text-button { padding: 5px 8px; color: var(--green-dark); background: transparent; border: 0; font-weight: 600; }
.text-button.danger { color: var(--red); }
.muted { color: var(--muted); }
.empty-row { padding: 42px !important; color: var(--muted); text-align: center !important; }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #eef0f2; }
.person { display: flex; align-items: center; gap: 10px; }
.person strong, .stacked strong { display: block; }
.person small, .stacked small { display: block; margin-top: 3px; color: var(--muted); }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 8px; color: #315f51; background: #e9f3ef; border-radius: 4px; font-size: 12px; }
.tag.neutral { color: #475467; background: #eef0f3; }
.tag.archived { color: #8a4b08; background: #fff1df; }

.editor-dialog { width: min(620px, calc(100% - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0; border-radius: 8px; box-shadow: 0 20px 60px rgba(16, 24, 40, .2); }
.editor-dialog::backdrop { background: rgba(17, 24, 39, .46); }
.dialog-header, .dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 19px; }
.dialog-body { max-height: calc(100vh - 190px); overflow-y: auto; padding: 20px; }
.dialog-footer { justify-content: flex-end; border-top: 1px solid var(--line); border-bottom: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.checkbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check-row { display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-weight: 500; }
.check-row input { width: 17px; min-height: 17px; margin: 0; padding: 0; }
.field-note { margin: -7px 0 15px; color: var(--muted); font-size: 13px; }
.upload-progress { height: 6px; overflow: hidden; margin: 4px 0 16px; background: #e7ebe9; border-radius: 3px; }
.upload-progress > div { width: 0; height: 100%; background: var(--green); transition: width .18s ease; }
.toast-region { position: fixed; z-index: 20; top: 78px; right: 22px; display: grid; gap: 8px; }
.toast { max-width: 380px; padding: 12px 15px; color: #fff; background: #344054; border-radius: 6px; box-shadow: 0 10px 25px rgba(16, 24, 40, .18); }
.toast.error { background: #9f2d24; }

@media (max-width: 820px) {
    .topbar { height: auto; min-height: 64px; grid-template-columns: 1fr 40px; padding: 12px 16px; }
    .organization-picker { grid-column: 1 / -1; grid-row: 2; justify-content: stretch; }
    .organization-picker select { flex: 1; }
    .workspace { display: block; min-height: 0; }
    .section-nav { position: sticky; z-index: 5; top: 0; display: flex; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
    .nav-item { flex: 0 0 auto; width: auto; margin: 0; }
    .content { padding: 20px 14px; }
    .metric-row { grid-template-columns: 1fr 1fr; }
    .table-shell { overflow-x: auto; }
    .data-table { min-width: 720px; }
}

@media (max-width: 520px) {
    .nav-item span { display: none; }
    .metric-row { grid-template-columns: 1fr; }
    .page-header { align-items: stretch; flex-direction: column; }
    .checkbox-grid, .form-grid { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
}
