:root {
    color-scheme: light;
    --coi-blue: #003e5f;
    --coi-blue-dark: #002d46;
    --coi-blue-soft: #e7f1f6;
    --coi-red: #f21a26;
    --bg-app: #f3f6f8;
    --bg-surface: #ffffff;
    --bg-subtle: #f5f8fa;
    --text-primary: #1d2a32;
    --text-secondary: #60717d;
    --border: #d6e0e6;
    --border-strong: #b8c7d0;
    --success: #246b45;
    --success-soft: #edf8f1;
    --warning: #855b0b;
    --warning-soft: #fff7df;
    --danger: #b4232e;
    --danger-soft: #fff0f1;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --font-sans: "Segoe UI", Inter, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    --font-mono: "Cascadia Mono", Consolas, "Courier New", monospace;
    --focus-ring: 0 0 0 3px rgba(0, 62, 95, 0.2);
    font-family: var(--font-sans);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--bg-app); color: var(--text-primary); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--coi-blue); text-underline-offset: 3px; }
a:hover { color: var(--coi-blue-dark); }
[hidden] { display: none !important; }
::selection { background: #c9e1ed; color: var(--coi-blue-dark); }
:focus-visible { outline: 2px solid var(--coi-blue); outline-offset: 2px; }

.skip-link { position: fixed; z-index: 1000; top: var(--space-2); left: var(--space-2); padding: 9px 12px; border-radius: var(--radius-sm); background: var(--coi-blue-dark); color: #fff; font-weight: 700; text-decoration: none; transform: translateY(-160%); }
.skip-link:focus { color: #fff; transform: translateY(0); }

.topbar { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); padding: 0 36px; border-bottom: 2px solid var(--coi-blue); background: #f7fafb; }
.topbar-main, .topnav, .user-area { display: flex; align-items: center; }
.topbar-main { align-self: stretch; gap: 18px; }
.brand-logo { width: 54px; height: 48px; display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; }
.brand-logo img { display: block; width: 52px; height: 52px; object-fit: contain; }
.topnav { align-self: stretch; gap: 2px; }
.topnav-link { position: relative; min-height: 44px; height: 100%; display: inline-flex; align-items: center; padding: 0 14px; color: #536671; font-size: 14px; font-weight: 650; text-decoration: none; }
.topnav-link:hover { background: var(--coi-blue-soft); color: var(--coi-blue-dark); }
.topnav-link.is-active { color: var(--coi-blue); }
.topnav-link.is-active::after { content: ""; position: absolute; right: 12px; bottom: -2px; left: 12px; height: 3px; background: var(--coi-blue); }
.topnav-link.is-active::before { content: ""; position: absolute; z-index: 1; bottom: -2px; left: 12px; width: 12px; height: 3px; background: var(--coi-red); }
.user-area { gap: 18px; color: var(--text-secondary); font-size: 13px; }
.user-name { white-space: nowrap; }
.logout { color: var(--coi-blue); font-weight: 650; text-decoration: none; }
button.logout { background: none; border: 0; padding: 0; font: inherit; font-weight: 650; cursor: pointer; }
.logout:hover { text-decoration: underline; }

.page { width: 100%; max-width: 1250px; margin: 0 auto; padding: 40px 32px 60px; }
.page-header { margin-bottom: var(--space-5); }
.page-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-5); }
h1 { margin: 0 0 7px; color: var(--coi-blue-dark); font-size: 27px; line-height: 1.2; font-weight: 680; letter-spacing: -0.35px; }
.intro { margin: 0; color: var(--text-secondary); font-size: 14px; line-height: 1.55; }

.button, .btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); padding: 0 16px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--bg-surface); color: var(--coi-blue-dark); font-size: 13px; font-weight: 680; text-decoration: none; cursor: pointer; transition: background-color 80ms linear, border-color 80ms linear, color 80ms linear; }
.button:hover, .btn:hover { border-color: #8ea5b2; background: var(--coi-blue-soft); color: var(--coi-blue-dark); }
.button:focus-visible, .btn:focus-visible { outline: 0; box-shadow: var(--focus-ring); }
.button-primary, .btn-primary { border-color: var(--coi-blue); background: var(--coi-blue); color: #fff; }
.button-primary:hover, .btn-primary:hover { border-color: var(--coi-blue-dark); background: var(--coi-blue-dark); color: #fff; }
.button-danger, .btn-danger { border-color: var(--danger); background: var(--danger); color: #fff; }
.button-danger:hover, .btn-danger:hover { border-color: #8f1924; background: #8f1924; color: #fff; }
.button-quiet, .btn-quiet { min-height: 34px; padding: 0 var(--space-2); border-color: transparent; background: transparent; color: var(--coi-blue); }
.button-small, .btn-small { min-height: 34px; padding: 0 12px; font-size: 12px; }
.button:disabled, .btn:disabled, .form-control:disabled, .search-input:disabled, .sort-select:disabled, .version-select:disabled { border-color: var(--border); background: #eef2f4; color: #7b8992; cursor: not-allowed; }
.button:disabled, .btn:disabled { opacity: 1; }

.form-field { display: block; margin-bottom: 14px; }
.form-label { display: flex; justify-content: space-between; gap: var(--space-2); margin-bottom: 6px; color: #344650; font-size: 13px; font-weight: 650; }
.required { color: var(--danger); font-size: 11px; font-weight: 700; }
.form-control, .search-input, .sort-select, .version-select { border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--bg-surface); color: var(--text-primary); outline: 0; }
.form-control { width: 100%; min-height: 40px; padding: 9px 10px; font-size: 14px; }
.form-control::placeholder, .search-input::placeholder { color: #8797a1; }
.form-control:hover, .search-input:hover, .sort-select:hover, .version-select:hover { border-color: #91a5b1; }
.form-control:focus, .search-input:focus, .sort-select:focus, .version-select:focus { border-color: var(--coi-blue); box-shadow: var(--focus-ring); }
.form-control:user-invalid, .search-input:user-invalid, .sort-select:user-invalid, .version-select:user-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(180, 35, 46, 0.14); }
textarea.form-control { min-height: 88px; resize: vertical; line-height: 1.4; }
.field-help { display: block; margin-top: 5px; color: var(--text-secondary); font-size: 12px; line-height: 1.35; }
input[type="checkbox"] { width: 17px; height: 17px; margin: 0; accent-color: var(--coi-blue); cursor: pointer; }
input[type="checkbox"]:focus-visible { outline: 2px solid var(--coi-blue); outline-offset: 2px; }

.panel { position: relative; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-surface); box-shadow: 0 1px 2px rgba(0, 45, 70, 0.035); }
.panel-accent { border-top: 3px solid var(--coi-blue); }
.panel-accent::before { content: ""; position: absolute; z-index: 2; top: 0; left: -1px; width: 20px; height: 3px; background: var(--coi-red); }
.panel-heading { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: 0 18px; border-bottom: 1px solid var(--border); background: var(--bg-subtle); }
.panel-heading h2 { margin: 0; color: var(--coi-blue-dark); font-size: 14px; font-weight: 700; }
.panel-caption { color: var(--text-secondary); font-size: 12px; }

.data-table-shell { width: 100%; overflow: hidden; }
.table-scroll { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead { background: var(--bg-subtle); }
.data-table th { padding: 12px 16px; border-bottom: 1px solid var(--border); color: #566b78; font-size: 11px; font-weight: 700; letter-spacing: 0.045em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 14px 16px; border-bottom: 1px solid #e7edf0; color: #344650; font-size: 13px; line-height: 1.35; vertical-align: middle; }
.data-table tbody tr:nth-child(even) { background: #fafcfd; }
.data-table tbody tr:hover { background: #eef5f8; }
.data-table tbody tr:has(input[type="checkbox"]:checked) { background: var(--coi-blue-soft); box-shadow: inset 3px 0 0 var(--coi-blue); }
.data-table tbody tr:last-child td { border-bottom: 0; }

.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-subtle); color: var(--text-secondary); font-size: 11px; font-weight: 680; text-transform: capitalize; white-space: nowrap; }
.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #8e9ca5; }
.status-badge.enabled, .status-badge.published, .status-badge.succeeded { border-color: #c5e2d0; background: var(--success-soft); color: var(--success); }
.status-badge.enabled::before, .status-badge.published::before, .status-badge.succeeded::before { background: var(--success); }
.status-badge.draft, .status-badge.running, .status-badge.queued { border-color: #e7d59e; background: var(--warning-soft); color: var(--warning); }
.status-badge.draft::before, .status-badge.running::before, .status-badge.queued::before { background: #b77a09; }
.status-badge.failed { border-color: #e9c2c6; background: var(--danger-soft); color: var(--danger); }
.status-badge.failed::before { background: var(--danger); }

.toolbar { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: 8px 12px 8px 16px; border: 1px solid #aac4d2; border-left: 3px solid var(--coi-blue); border-radius: var(--radius-md); background: #f8fbfc; color: var(--coi-blue-dark); font-size: 13px; }
.notice { padding: 12px 14px; border: 1px solid var(--border); border-left: 3px solid var(--coi-blue); border-radius: var(--radius-md); background: var(--bg-surface); color: #42555f; font-size: 13px; line-height: 1.45; }
.notice-info { border-color: #bdd2dc; border-left-color: var(--coi-blue); background: #f2f8fb; color: #38515e; }
.notice-error { border-color: #e5b8bd; border-left-color: var(--danger); background: var(--danger-soft); color: #7e2730; }
.notice-success { border-color: #b9d9c5; border-left-color: var(--success); background: var(--success-soft); color: #205b3b; }

.empty { padding: 64px 24px; color: var(--text-secondary); text-align: center; }
.empty-title { margin-bottom: 6px; color: var(--coi-blue-dark); font-size: 15px; font-weight: 680; }
.empty-text { margin: 0; font-size: 13px; }
.pagination-wrapper { display: flex; justify-content: center; margin-top: var(--space-5); }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-1); }
.pagination a, .pagination span { min-width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; padding: 0 10px; border-radius: var(--radius-sm); color: #405762; font-size: 13px; text-decoration: none; white-space: nowrap; }
.pagination a:hover { background: var(--coi-blue-soft); color: var(--coi-blue-dark); }
.pagination .current { background: var(--coi-blue); color: #fff; font-weight: 700; }
.pagination .disabled { color: #9ba7ae; }
.pagination .ellipsis { color: #7f8d96; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.coi-dialog { width: min(460px, calc(100vw - 28px)); padding: 0; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--bg-surface); color: var(--text-primary); box-shadow: 0 24px 72px rgba(0, 38, 56, .28); }
.coi-dialog::backdrop { background: rgba(13, 34, 46, .52); backdrop-filter: blur(2px); }
.coi-dialog form { padding: 0; }
.coi-dialog-heading { padding: 20px 22px 14px; border-top: 4px solid var(--coi-blue); border-bottom: 1px solid var(--border); background: var(--bg-subtle); }
.coi-dialog-heading::before { content: ""; position: absolute; top: 0; left: 0; width: 36px; height: 4px; background: var(--coi-red); }
.coi-dialog-heading h2 { margin: 3px 0 0; color: var(--coi-blue-dark); font-size: 19px; line-height: 1.25; }
.coi-dialog-eyebrow { color: var(--text-secondary); font-size: 10px; font-weight: 750; letter-spacing: .075em; text-transform: uppercase; }
.coi-dialog-message { margin: 0; padding: 18px 22px 0; color: #42555f; white-space: pre-line; }
.coi-dialog .form-field { padding: 16px 22px 0; }
.coi-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 20px 22px 22px; }
.coi-dialog-danger #coi-dialog-accept { border-color: var(--danger); background: var(--danger); }
.coi-dialog-danger #coi-dialog-accept:hover { border-color: #8f1924; background: #8f1924; }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-5); background: #eef3f6; }
.login-card { width: 100%; max-width: 430px; padding: 42px 40px 34px; text-align: center; }
.login-card .logo { width: 112px; height: 112px; margin-bottom: 22px; border-radius: var(--radius-md); object-fit: contain; }
.login-card h1 { margin-bottom: 9px; font-size: 27px; }
.login-card .subtitle { margin: 0 0 28px; color: var(--text-secondary); font-size: 14px; line-height: 1.55; }
.microsoft-button { width: 100%; min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 11px; padding: 0 18px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--bg-surface); color: var(--coi-blue-dark); font-size: 14px; font-weight: 680; text-decoration: none; }
.microsoft-button:hover { border-color: var(--coi-blue); background: var(--coi-blue-soft); color: var(--coi-blue-dark); }
.microsoft-logo { display: grid; grid-template-columns: 8px 8px; grid-template-rows: 8px 8px; gap: 2px; }
.microsoft-logo span { width: 8px; height: 8px; }
.microsoft-logo span:nth-child(1) { background: #f25022; }
.microsoft-logo span:nth-child(2) { background: #7fba00; }
.microsoft-logo span:nth-child(3) { background: #00a4ef; }
.microsoft-logo span:nth-child(4) { background: #ffb900; }
.login-card .footer { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--border); color: #788892; font-size: 12px; }

@media (max-width: 850px) {
    .topbar { padding: 0 20px; }
    .page { padding: 32px 18px 50px; }
}

@media (max-width: 560px) {
    .topbar { min-height: 62px; gap: 10px; padding: 7px 14px; }
    .topbar-main { gap: 8px; }
    .brand-logo { width: 40px; height: 36px; }
    .brand-logo img { width: 40px; height: 40px; }
    .topnav-link { padding: 0 9px; font-size: 13px; }
    .user-name { display: none; }
    .user-area { gap: var(--space-2); }
    h1 { font-size: 24px; }
    .page-header-row { flex-direction: column; align-items: stretch; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .login-card { padding: 34px 24px 28px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
