:root {
    color-scheme: light;
    --ink: #172033;
    --muted: #667085;
    --line: #e3e8ef;
    --surface: #ffffff;
    --canvas: #f5f7fb;
    --brand: #1d4ed8;
    --brand-dark: #173b8f;
    --success-bg: #e8f7ef;
    --success-ink: #136c42;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at top right, rgba(29, 78, 216, 0.08), transparent 30rem),
        var(--canvas);
}

a { color: inherit; }

.app-header {
    min-height: 64px;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
}

.brand {
    color: var(--brand-dark);
    font-weight: 750;
    text-decoration: none;
    letter-spacing: -0.02em;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 18px;
    color: var(--muted);
    font-size: 0.9rem;
}

.app-nav { display: flex; gap: 8px; margin-right: auto; margin-left: 34px; }
.app-nav a { padding: 8px 10px; color: var(--muted); font-size: .9rem; font-weight: 650; text-decoration: none; }
.app-nav a:hover { color: var(--brand); }

.page-shell {
    width: min(1100px, calc(100% - 32px));
    margin: 48px auto;
}

.hero-card,
.content-card,
.auth-card {
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: 0 16px 44px rgba(29, 43, 74, 0.07);
}

.hero-card {
    padding: clamp(28px, 5vw, 64px);
    background: linear-gradient(135deg, #fff 35%, #edf3ff);
}

.hero-card h1,
.auth-card h1 {
    max-width: 760px;
    margin: 8px 0 12px;
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 1.02;
    letter-spacing: -0.05em;
}

.hero-card p:not(.eyebrow),
.auth-card p:not(.eyebrow) {
    color: var(--muted);
}

.eyebrow {
    margin: 0;
    color: var(--brand);
    font-size: 0.75rem;
    font-weight: 750;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.content-card { margin-top: 18px; padding: 24px; }

.page-intro { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 8px 2px; }
.page-intro h1 { margin: 6px 0 8px; font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.04em; }
.page-intro p:not(.eyebrow) { margin: 0; color: var(--muted); }
.compact-intro { margin-bottom: 8px; }
.breadcrumb { color: var(--brand); font-size: .86rem; font-weight: 700; text-decoration: none; }
.action-row, .form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.button-link { display: inline-flex; align-items: center; justify-content: center; margin-top: 0; text-decoration: none; }
.secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 10px 14px; border: 1px solid #cfd7e3; border-radius: 10px; color: var(--ink); background: #fff; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
.secondary-button:hover { border-color: var(--brand); color: var(--brand); }

.definition-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-top: 18px; }
.definition-card { display: grid; gap: 6px; min-height: 104px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: linear-gradient(155deg, #fff, #f8faff); text-decoration: none; transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease; }
.definition-card:hover { transform: translateY(-2px); border-color: #a9c0f3; box-shadow: 0 10px 24px rgba(29, 78, 216, .1); }
.definition-card strong { display: flex; align-items: center; gap: 9px; }
.definition-icon { display: inline-grid; width: 26px; height: 26px; place-items: center; border-radius: 8px; color: var(--brand); background: #e9f0ff; font-size: 1rem; }
.definition-card span, .definition-card small { color: var(--muted); }
.definition-card small { margin-top: auto; color: var(--brand); font-weight: 650; }
.master-group { padding: 24px 28px; }

.data-card { padding: 0; overflow: hidden; }
.data-toolbar { display: flex; align-items: end; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); background: #fbfcff; }
.data-toolbar label, .search-field { display: grid; gap: 6px; color: var(--muted); font-size: .78rem; font-weight: 750; }
.search-field { width: min(410px, 100%); flex: 1; }
.data-toolbar input, .data-toolbar select, .field-control, .bulk-table input { min-height: 36px; padding: 7px 9px; border: 1px solid #cfd7e3; border-radius: 8px; color: var(--ink); background: #fff; font: inherit; font-size: .9rem; }
.data-toolbar input:focus, .data-toolbar select:focus, .field-control:focus, .bulk-table input:focus { border-color: var(--brand); outline: 3px solid rgba(29, 78, 216, .12); }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: .9rem; }
.data-table th { position: sticky; top: 0; z-index: 1; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--muted); background: #fff; font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 10px 14px; border-bottom: 1px solid #edf0f5; vertical-align: middle; }
.data-table tbody tr:hover { background: #f8faff; }
.editable-row { cursor: pointer; }
.editable-row:focus { outline: 2px solid var(--brand); outline-offset: -2px; }
.data-table tr:last-child td { border-bottom: 0; }
.table-action { color: var(--brand); font-weight: 720; text-decoration: none; }
.empty-table { padding: 44px !important; color: var(--muted); text-align: center; }
.table-note { margin: 0; padding: 13px 22px; color: var(--muted); border-top: 1px solid var(--line); font-size: .8rem; }

.form-card { padding: 24px; }
.master-form { display: grid; gap: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-field { display: grid; gap: 7px; }
.form-field label { font-size: .84rem; font-weight: 750; }
.form-field-wide { grid-column: 1 / -1; }
.form-field textarea.field-control { resize: vertical; }
.form-field small { color: var(--muted); }
.field-error { color: #b42318 !important; }
.bulk-table td { padding: 7px 12px; }
.bulk-table input[type="text"] { width: 100%; min-width: 140px; }
.checkbox-cell { width: 80px; text-align: center; }
.checkbox-cell input { width: 18px; height: 18px; accent-color: var(--brand); }
.bulk-form .form-actions { padding: 18px 22px; border-top: 1px solid var(--line); }
.message-stack { display: grid; gap: 8px; margin-bottom: 18px; }
.message { padding: 12px 14px; border: 1px solid #b9e5c7; border-radius: 10px; color: var(--success-ink); background: var(--success-bg); font-size: .9rem; }
.message-error { border-color: #f4c7c7; color: #9d2525; background: #fff0f0; }
.lock-notice { margin: 0 0 18px; padding: 12px 14px; border: 1px solid #f5d58d; border-radius: 10px; color: #7a5100; background: #fff8df; }
.compact-button { min-height: 36px; margin-top: 0; padding: 8px 11px; border-radius: 8px; font-size: .86rem; }
.danger-button { min-height: 36px; padding: 8px 11px; border: 1px solid #efb1b1; border-radius: 8px; color: #b42318; background: #fff5f5; font: inherit; font-size: .86rem; font-weight: 700; cursor: pointer; }
.danger-button:hover { border-color: #b42318; background: #ffebeb; }
.icon-action { min-width: 30px; min-height: 30px; padding: 0; border: 0; border-radius: 7px; color: var(--brand); background: #eef4ff; font-size: 1rem; cursor: pointer; }
.icon-action:hover { background: #dce8ff; }

.record-dialog { width: min(900px, calc(100vw - 32px)); height: min(720px, calc(100vh - 32px)); padding: 0; border: 0; border-radius: 16px; background: #fff; box-shadow: 0 28px 80px rgba(15, 23, 42, .35); }
.record-dialog::backdrop { background: rgba(15, 23, 42, .52); backdrop-filter: blur(3px); }
.dialog-shell { display: grid; height: 100%; grid-template-rows: 46px minmax(0, 1fr); }
.dialog-bar { display: flex; align-items: center; justify-content: space-between; padding: 0 15px; color: #fff; background: linear-gradient(100deg, #173b8f, #1d4ed8); font-size: .9rem; font-weight: 750; }
.dialog-close { width: 28px; height: 28px; border: 0; border-radius: 7px; color: #fff; background: rgba(255, 255, 255, .16); font-size: 1.25rem; cursor: pointer; }
.record-editor-frame { width: 100%; height: 100%; border: 0; background: #fff; }
.modal-form-page { min-height: 100vh; padding: 20px; background: #fff; }
.modal-master-form { gap: 18px; }
.modal-form-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.modal-form-heading h1 { margin: 4px 0 0; font-size: 1.35rem; letter-spacing: -.025em; }
.modal-form-icon { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 10px; color: var(--brand); background: #eaf1ff; font-size: 1.15rem; }
.compact-form-grid { gap: 12px; }
.compact-form-grid .form-field { gap: 5px; }
.compact-form-grid .form-field label { font-size: .78rem; }
.compact-form-grid .form-field.is-disabled { opacity: .48; }
.compact-form-grid .form-field.is-disabled .field-control { cursor: not-allowed; background: #f3f5f8; }
.modal-form-actions { padding-top: 14px; border-top: 1px solid var(--line); }
.searchable-select { position: relative; }
.enhanced-select-native { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.searchable-select-trigger { width: 100%; min-height: 36px; padding: 7px 32px 7px 9px; overflow: hidden; border: 1px solid #cfd7e3; border-radius: 8px; color: var(--muted); background: #fff; background-image: linear-gradient(45deg, transparent 50%, #667085 50%), linear-gradient(135deg, #667085 50%, transparent 50%); background-position: calc(100% - 14px) 15px, calc(100% - 10px) 15px; background-size: 4px 4px, 4px 4px; background-repeat: no-repeat; font: inherit; font-size: .9rem; text-align: left; cursor: pointer; }
.searchable-select-trigger.has-value { color: var(--ink); }
.searchable-select-trigger:focus { border-color: var(--brand); outline: 3px solid rgba(29, 78, 216, .12); }
.searchable-select-panel { position: absolute; z-index: 10; top: calc(100% + 5px); display: none; width: 100%; min-width: 260px; padding: 8px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; box-shadow: 0 16px 32px rgba(15, 23, 42, .16); }
.searchable-select-panel.is-open { display: block; }
.searchable-select-search { width: 100%; min-height: 34px; padding: 7px 9px; border: 1px solid #d8dee9; border-radius: 7px; font: inherit; font-size: .85rem; }
.searchable-select-options { max-height: 210px; margin-top: 7px; overflow-y: auto; }
.searchable-select-option, .searchable-select-columns { display: grid; grid-template-columns: minmax(0, 1fr) 72px; gap: 10px; width: 100%; padding: 8px 9px; border: 0; color: var(--ink); background: transparent; font: inherit; font-size: .84rem; text-align: left; }
.searchable-select-option { border-radius: 6px; cursor: pointer; }
.searchable-select-option:hover, .searchable-select-option.is-selected { background: #edf3ff; color: var(--brand-dark); }
.searchable-select-option span:last-child, .searchable-select-columns span:last-child { color: var(--muted); text-align: right; }
.searchable-select-columns { padding-top: 2px; padding-bottom: 5px; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.select-empty { margin: 12px 8px; color: var(--muted); font-size: .82rem; }
.table-checkbox { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); vertical-align: middle; }
.import-card { max-width: 840px; }
.import-upload-row { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px dashed #b8c8e6; border-radius: 12px; background: #f8faff; }
.import-upload-row div { display: grid; gap: 6px; }
.import-upload-row small { color: var(--muted); font-size: .82rem; }
.import-upload-row input[type="file"] { font: inherit; font-size: .86rem; }
.import-icon { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 10px; color: var(--brand); background: #e4edff; font-size: 1.25rem; }
.import-columns { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.import-columns span { padding: 6px 9px; border: 1px solid #dbe3f0; border-radius: 7px; color: #334155; background: #f8fafc; font-size: .78rem; }
.required-settings-form { gap: 14px; }
.required-definition-card { margin-top: 0; padding: 18px 22px; }
.required-field-grid { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }
.required-field-option { display: inline-flex; align-items: center; gap: 7px; min-height: 35px; padding: 7px 10px; border: 1px solid #dbe3f0; border-radius: 8px; background: #fbfcff; font-size: .85rem; cursor: pointer; }
.required-field-option:hover { border-color: #9db7eb; }
.required-field-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.required-field-option small { color: var(--muted); font-size: .72rem; }
.required-field-option.is-global { color: #475569; background: #f1f5f9; cursor: not-allowed; }
.required-marker { margin-left: 3px; color: #d92d20; font-weight: 800; }
.required-marker.is-hidden { display: none; }

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

.section-heading h2 { margin: 6px 0 0; }

.status-pill {
    padding: 7px 10px;
    border-radius: 999px;
    color: var(--success-ink);
    background: var(--success-bg);
    font-size: 0.75rem;
    font-weight: 700;
}

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

.membership-card {
    display: grid;
    gap: 5px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.membership-card span,
.membership-card small,
.empty-state { color: var(--muted); }

.auth-card {
    width: min(440px, 100%);
    margin: 10vh auto 0;
    padding: 34px;
}

.auth-card h1 { font-size: 2.4rem; }

.auth-form { display: grid; gap: 10px; margin-top: 24px; }

.auth-form label { margin-top: 8px; font-size: 0.85rem; font-weight: 700; }

.auth-form input {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid #cfd7e3;
    border-radius: 10px;
    font: inherit;
}

.auth-form input:focus {
    border-color: var(--brand);
    outline: 3px solid rgba(29, 78, 216, 0.12);
}

.primary-button {
    margin-top: 14px;
    padding: 12px 16px;
    border: 0;
    border-radius: 10px;
    color: white;
    background: var(--brand);
    font: inherit;
    font-weight: 750;
    cursor: pointer;
}

.primary-button:hover { background: var(--brand-dark); }

.link-button {
    border: 0;
    padding: 0;
    color: var(--brand);
    background: transparent;
    font: inherit;
    cursor: pointer;
}

.error-box {
    margin-top: 18px;
    padding: 12px;
    border-radius: 10px;
    color: #9d2525;
    background: #fff0f0;
}

@media (max-width: 680px) {
    .app-header { padding: 0 16px; }
    .header-meta span { display: none; }
    .app-nav { margin-left: 8px; }
    .page-shell { margin-top: 22px; }
    .section-heading { align-items: flex-start; flex-direction: column; }
    .page-intro { align-items: flex-start; flex-direction: column; }
    .data-toolbar { align-items: stretch; flex-direction: column; }
    .form-grid { grid-template-columns: 1fr; }
}
