:root {
    --esri-blue: #0079c1;
    --esri-blue-dark: #005e95;
    --ink: #1f2933;
    --ink-muted: #5f6b76;
    --line: #dde3e8;
    --surface: #ffffff;
    --background: #f4f6f8;
    --success: #2e7d32;
    --danger: #b3261e;
    --radius: 8px;
    color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--background);
    color: var(--ink);
    font-family: "Segoe UI", "Avenir Next", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

body { display: flex; min-height: 100vh; flex-direction: column; }

a { color: var(--esri-blue); }
h1 { font-size: 1.9rem; margin: 0 0 0.75rem; line-height: 1.2; }
h1:focus { outline: none; }
h2 { font-size: 1.2rem; margin: 0 0 0.5rem; }
.muted { color: var(--ink-muted); }

/* Header */
.topbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 3px solid var(--esri-blue);
}
.brand { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); line-height: 1.2; }
.brand-org { font-size: 0.8rem; color: var(--ink-muted); }
.brand-app { font-size: 1.15rem; font-weight: 600; }
.topnav { display: flex; gap: 1rem; flex: 1; }
.topnav a { text-decoration: none; color: var(--ink); padding: 0.25rem 0; border-bottom: 2px solid transparent; }
.topnav a.active { border-bottom-color: var(--esri-blue); color: var(--esri-blue); }
.account { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }
.account form { margin: 0; }
.account-name { color: var(--ink-muted); font-size: 0.9rem; }

/* Layout */
.content { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }
.footer {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
    padding: 1rem 1.5rem; font-size: 0.85rem; color: var(--ink-muted);
    border-top: 1px solid var(--line); background: var(--surface);
}

/* Components */
.hero { margin-bottom: 1.5rem; }
.lead { font-size: 1.1rem; color: var(--ink-muted); max-width: 60ch; }
.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.25rem 1.5rem; margin-bottom: 1rem;
}
.card.empty { text-align: center; padding: 2.5rem 1.5rem; }
.signin-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.signin-options .card { margin: 0; display: flex; flex-direction: column; align-items: flex-start; }
.signin-options .card p { flex: 0; }
.hint { font-size: 0.85rem; color: var(--ink-muted); margin-bottom: 0; }

.button {
    display: inline-block; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
    padding: 0.55rem 1.1rem; border-radius: 6px; border: 1px solid transparent;
}
.button-primary { background: var(--esri-blue); color: #fff; }
.button-primary:hover { background: var(--esri-blue-dark); }
.button-secondary { background: var(--surface); color: var(--esri-blue); border-color: var(--esri-blue); }
.button-secondary:hover { background: #e8f3fa; }
.button-link { background: none; border: none; padding: 0; color: var(--esri-blue); font-weight: 400; }
.button-link:hover { text-decoration: underline; }
.button:focus-visible, .topnav a:focus-visible { outline: 3px solid #8cc8ea; outline-offset: 2px; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.arabic { margin: 0; color: var(--ink-muted); font-size: 1.1rem; }
/* Arabic runs keep right-to-left direction but line up with the surrounding left-aligned layout. */
.rtl-text { direction: rtl; unicode-bidi: isolate; display: inline-block; }
.badge {
    background: #e8f3fa; color: var(--esri-blue-dark); border-radius: 999px;
    padding: 0.2rem 0.8rem; font-weight: 600; font-size: 0.9rem; white-space: nowrap;
}
.notice {
    background: #fff8e1; border: 1px solid #f3d27a; border-radius: var(--radius);
    padding: 0.75rem 1rem; margin-bottom: 1rem;
}

.details { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.5rem; margin: 0; }
.details dt { color: var(--ink-muted); }
.details dd { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.stat {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1rem 1.25rem; display: flex; flex-direction: column;
}
.stat-value { font-size: 1.8rem; font-weight: 600; }
.stat-label { color: var(--ink-muted); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.65rem 1rem; text-align: left; border-bottom: 1px solid var(--line); }
.table th { font-size: 0.85rem; color: var(--ink-muted); font-weight: 600; background: #fafbfc; }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; }
.status { font-size: 0.85rem; font-weight: 600; }
.status-active { color: var(--success); }
.status-inactive { color: var(--danger); }

/* Blazor framework UI */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "An error has occurred."; }

/* Utilities */
.small { font-size: 0.85rem; }
.pre-line { white-space: pre-line; }
.text-danger { color: var(--danger); }
.text-warning { color: #9a6700; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.breadcrumb { font-size: 0.9rem; color: var(--ink-muted); margin: 0 0 0.5rem; }
.badges { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.badge-muted { background: #eceff1; color: var(--ink-muted); }
.tag {
    display: inline-block; font-size: 0.75rem; font-weight: 600; margin: 0 0.25rem 0.25rem 0;
    padding: 0.05rem 0.5rem; border-radius: 999px; background: #eef2f5; color: var(--ink-muted);
}

/* Sections, banners and tabs */
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }
.section-header h2 { margin: 0; }
h3 { font-size: 1.05rem; margin: 0 0 0.75rem; }
.banner {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
    border-radius: var(--radius); padding: 0.65rem 1rem; margin-bottom: 1rem;
}
.banner-success { background: #e8f5e9; border: 1px solid #a5d6a7; }
.banner-error { background: #fdecea; border: 1px solid #f5b5ae; }
.banner-close { background: none; border: none; font-size: 1.2rem; line-height: 1; cursor: pointer; color: var(--ink-muted); }
.review {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    border-radius: var(--radius); padding: 0.85rem 1.25rem; margin-bottom: 1rem;
}
.review-due { background: #fff8e1; border: 1px solid #f3d27a; }
.review-ok { background: var(--surface); border: 1px solid var(--line); }
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tab {
    font: inherit; background: none; border: none; border-bottom: 3px solid transparent; cursor: pointer;
    padding: 0.6rem 0.9rem; color: var(--ink-muted); white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab-active { color: var(--esri-blue); border-bottom-color: var(--esri-blue); font-weight: 600; }
.tab-count { font-size: 0.8rem; color: var(--ink-muted); margin-left: 0.2rem; }
.tab:focus-visible { outline: 3px solid #8cc8ea; outline-offset: -3px; }

/* Forms */
.toolbar { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input[type=search] { flex: 1; min-width: 220px; }
input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea {
    font: inherit; color: var(--ink); background: var(--surface); width: 100%;
    border: 1px solid #b8c2cc; border-radius: 6px; padding: 0.45rem 0.6rem;
}
.toolbar select { width: auto; }
input:focus, select:focus, textarea:focus { outline: 3px solid #8cc8ea; outline-offset: 0; border-color: var(--esri-blue); }
input:disabled { background: #f0f2f4; color: var(--ink-muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.9rem 1.25rem; }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field label { font-weight: 600; font-size: 0.9rem; }
.field-wide { grid-column: 1 / -1; }
.field-check { flex-direction: row; align-items: center; gap: 0.5rem; align-self: end; padding-bottom: 0.5rem; }
.field .hint { font-size: 0.8rem; color: var(--ink-muted); }
.checks { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin: 1rem 0 0; }
.checks label { display: flex; align-items: center; gap: 0.4rem; }
.check-emphasis { font-weight: 600; color: var(--esri-blue-dark); }
.fieldset { border: 1px dashed #b8c2cc; border-radius: var(--radius); padding: 0.75rem 1rem 1rem; margin: 0 0 1.25rem; }
.fieldset legend { font-size: 0.85rem; font-weight: 600; color: var(--ink-muted); padding: 0 0.4rem; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.25rem; }
.subform { background: #f8fafb; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.button:disabled { opacity: 0.6; cursor: default; }
.button-small { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.button-danger { background: var(--danger); color: #fff; }
.link-danger { color: var(--danger); }
.actions { white-space: nowrap; text-align: right; }
.actions .button-link { margin-left: 0.75rem; }
.actions-col { width: 1%; }
.header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }
.import-stats { margin: 1rem 0; }
.plain-list { margin: 0 0 0.75rem; padding-left: 1.1rem; }
.plain-list li { margin-bottom: 0.4rem; }
.spaced { margin-top: 1.25rem; }
.card.notice-warning { background: #fff8e1; border-color: #f3d27a; }

/* Change history */
.history { list-style: none; margin: 0; padding: 0; }
.history-entry { display: grid; grid-template-columns: 220px 1fr; gap: 1rem; padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.history-entry:last-child { border-bottom: none; }
.history-meta { display: flex; flex-direction: column; font-size: 0.85rem; }
.history-when { font-weight: 600; }
.history-who { color: var(--ink-muted); word-break: break-word; }
.history-changes { margin: 0.35rem 0 0; padding-left: 1.1rem; font-size: 0.9rem; }
.history-before { text-decoration: line-through; color: var(--ink-muted); }
.tag-added { background: #e8f5e9; color: var(--success); }
.tag-changed { background: #e8f3fa; color: var(--esri-blue-dark); }
.tag-removed { background: #fdecea; color: var(--danger); }

@media (max-width: 640px) {
    .topbar { flex-wrap: wrap; gap: 0.75rem; }
    .account-name { display: none; }
    .details { grid-template-columns: 1fr; }
    .details dd { margin-bottom: 0.5rem; }
    .actions { white-space: normal; }
    .history-entry { grid-template-columns: 1fr; gap: 0.25rem; }
    .header-actions { justify-content: flex-start; }
}
