:root {
    --brand-blue: #075c87;
    --brand-blue-dark: #063d5c;
    --brand-sky: #d9f1fb;
    --brand-orange: #f18700;
    --ink: #163044;
    --muted: #647787;
    --border: #dbe5eb;
    --surface: #ffffff;
    --background: #f4f8fa;
    --success: #198754;
    --danger: #b42318;
    --warning: #9a5b00;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: var(--ink);
    background: var(--background);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body { min-height: 100vh; margin: 0; background: var(--background); color: var(--ink); }
button, input, select, textarea { font: inherit; }
a { color: var(--brand-blue); }

.app-header { background: var(--brand-sky); border-bottom: 1px solid #c4e4f1; }
.header-content { max-width: 1240px; min-height: 76px; margin: auto; padding: 12px 28px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 16px; color: var(--brand-blue-dark); text-decoration: none; }
.brand-mark, .login-brand { font-size: 27px; font-weight: 850; letter-spacing: -2px; }
.brand-mark span, .login-brand span { color: var(--brand-orange); }
.brand-divider { width: 1px; height: 30px; background: #9bc9dc; }
.brand-product { font-weight: 650; font-size: 14px; }
.environment-badge { padding: 8px 13px; border-radius: 999px; background: rgba(255,255,255,.72); color: var(--brand-blue); font-size: 13px; font-weight: 650; white-space: nowrap; }
.environment-badge span { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--success); }
.account-area { display: flex; align-items: center; gap: 14px; color: var(--brand-blue-dark); font-size: 13px; font-weight: 650; }
.language-picker { display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 8px 0 9px; border: 1px solid #a9c8d7; border-radius: 999px; background: rgba(255,255,255,.84); color: var(--brand-blue); }
.language-picker:focus-within { border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(7,92,135,.12); }
.language-icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.language-picker select { width: auto; min-width: 40px; height: 30px; padding: 0 16px 0 0; border: 0; border-radius: 0; background-color: transparent; background-position: right 1px center; color: var(--brand-blue-dark); font-size: 12px; font-weight: 800; box-shadow: none; }
.language-picker select:focus { border: 0; box-shadow: none; }

.admin-nav { background: white; border-bottom: 1px solid var(--border); }
.admin-nav > div { max-width: 1240px; margin: auto; padding: 0 28px; display: flex; gap: 8px; overflow-x: auto; }
.admin-nav a { padding: 15px 13px 13px; border-bottom: 3px solid transparent; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 700; white-space: nowrap; }
.admin-nav a:hover, .admin-nav a.active { color: var(--brand-blue); border-bottom-color: var(--brand-orange); }

.page-shell { max-width: 1240px; min-height: calc(100vh - 190px); margin: 0 auto; padding: 38px 28px 64px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 32px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 8px; color: var(--brand-orange); font-size: 12px; font-weight: 800; letter-spacing: .11em; }
h1 { margin: 0; color: var(--brand-blue-dark); font-size: clamp(29px, 4vw, 42px); line-height: 1.1; letter-spacing: -.035em; }
h1:focus { outline: none; }
h2 { color: var(--brand-blue-dark); }
.page-description { max-width: 760px; margin: 13px 0 0; color: var(--muted); line-height: 1.55; }

.panel { margin-bottom: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 25px; box-shadow: 0 7px 22px rgba(6,61,92,.045); }
.panel-heading { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 23px; }
.panel-heading.compact { margin-bottom: 15px; }
.panel-heading h2, .clone-panel h2 { margin: 0 0 4px; font-size: 20px; }
.panel-heading p, .clone-panel p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.step-number { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px; color: white; background: var(--brand-blue); font-weight: 750; }
.narrow-panel { max-width: 620px; }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 20px; }
.metric-card { display: grid; gap: 9px; padding: 22px; background: white; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 7px 22px rgba(6,61,92,.045); }
.metric-card > span { color: var(--muted); font-size: 12px; }
.metric-card strong { color: var(--brand-blue-dark); font-size: 26px; }
.metric-card a { font-size: 12px; font-weight: 700; text-decoration: none; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.check-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.check-list li { display: flex; align-items: center; gap: 10px; padding: 12px; background: #f8fafb; border-radius: 8px; }
.check-list span { width: 10px; height: 10px; border-radius: 50%; background: #a9b8c2; }
.check-list .ok span { background: var(--success); box-shadow: 0 0 0 4px rgba(25,135,84,.11); }
.check-list .pending span { background: var(--brand-orange); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.stack-form { display: grid; gap: 17px; }
.field-group { display: grid; gap: 7px; }
.reader-selector { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; align-items: center; }
.field-group label { color: var(--brand-blue-dark); font-size: 13px; font-weight: 700; }
.field-group small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.full-width { grid-column: 1 / -1; }
input, select, textarea { width: 100%; border: 1px solid #bccbd5; border-radius: 8px; background: white; color: var(--ink); padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(7,92,135,.12); }
input:disabled, select:disabled, textarea:disabled, fieldset:disabled input, fieldset:disabled select, fieldset:disabled textarea { background: #f2f5f6; color: #7d8d98; }
textarea { resize: vertical; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.validation-message { color: var(--danger); font-size: 12px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; border: 0; border-radius: 8px; padding: 9px 18px; cursor: pointer; font-weight: 700; text-decoration: none; transition: transform .12s, background .12s, opacity .12s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .48; cursor: not-allowed; }
.button.primary { background: var(--brand-orange); color: white; box-shadow: 0 6px 14px rgba(241,135,0,.2); }
.button.primary:hover:not(:disabled) { background: #db7700; }
.button.secondary { background: #eaf4f8; color: var(--brand-blue); }
.button.outline { background: white; color: var(--brand-blue); border: 1px solid var(--brand-blue); }
.button.outline:hover:not(:disabled) { background: #f2f8fb; }
.button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.button.danger { background: #fff1ef; color: var(--danger); border: 1px solid #efc0bb; }
.button.danger:hover:not(:disabled) { background: #ffe5e1; }
.button.compact { min-height: 34px; padding: 6px 11px; }
.actions { display: flex; gap: 9px; align-items: center; }

.alert { margin: 0 0 18px; padding: 13px 15px; border-radius: 9px; font-size: 13px; line-height: 1.45; }
.alert.error { color: var(--danger); background: #fff1ef; border: 1px solid #efc0bb; }
.alert.success { color: #12633d; background: #edf8f2; border: 1px solid #b8dec9; }
.alert.warning { color: var(--warning); background: #fff8ed; border: 1px solid #f7d7a4; }
.password-warning { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.empty-state { padding: 16px; color: var(--muted); background: #f8fafb; border: 1px dashed #abc4d1; border-radius: 9px; }
.empty-state h1, .empty-state h2 { color: var(--brand-blue-dark); }

.file-upload { display: flex; align-items: center; gap: 14px; padding: 13px; border: 1px dashed #abc4d1; border-radius: 9px; background: #f8fbfc; }
.file-upload input { width: auto; max-width: 310px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.file-upload input::file-selector-button { margin-right: 12px; padding: 9px 14px; border: 1px solid var(--brand-blue); border-radius: 7px; background: white; color: var(--brand-blue); font-weight: 750; cursor: pointer; }
.file-upload div { display: grid; gap: 3px; }
.file-upload strong { font-size: 13px; }
.file-upload span { color: var(--muted); font-size: 11px; }
.json-details { margin-top: 17px; border-top: 1px solid #edf1f3; padding-top: 13px; }
.json-details summary { color: var(--brand-blue); cursor: pointer; font-size: 13px; font-weight: 700; }
.json-details textarea { margin-top: 11px; font-family: Consolas, monospace; font-size: 12px; }

.option-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.toggle-card { display: flex; align-items: flex-start; gap: 11px; padding: 14px; border: 1px solid var(--border); border-radius: 9px; background: #f8fafb; cursor: pointer; }
.toggle-card.risk { background: #fffaf3; border-color: #f1d7af; }
.toggle-card input { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--brand-blue); }
.toggle-card span { display: grid; gap: 3px; }
.toggle-card strong { color: var(--brand-blue-dark); font-size: 13px; }
.toggle-card small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.availability-toggle { min-height: 54px; align-items: center; padding: 10px 14px; }
.availability-toggle input { margin-top: 0; }
.credential-panel { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px; border: 1px solid var(--border); border-radius: 9px; background: #f8fafb; }
.credential-panel div { display: grid; gap: 3px; }
.credential-panel strong { color: var(--brand-blue-dark); font-size: 13px; }
.credential-panel small { color: var(--muted); font-size: 11px; }
.future-notice { display: grid; gap: 4px; padding: 15px 16px; border-left: 3px solid var(--brand-orange); border-radius: 0 8px 8px 0; background: #fffaf3; }
.future-notice strong { color: var(--brand-blue-dark); font-size: 13px; }
.future-notice span { color: var(--muted); font-size: 13px; line-height: 1.45; }
.action-bar { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 17px 25px; background: #f8fafb; border: 1px solid var(--border); border-radius: 12px; }
.action-bar.standalone { margin-bottom: 20px; }
.readiness { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.status-dot { width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: #a9b8c2; }
.status-dot.ok { background: var(--success); box-shadow: 0 0 0 4px rgba(25,135,84,.11); }
.status-dot.error { background: var(--danger); box-shadow: 0 0 0 4px rgba(180,35,24,.1); }
.clone-panel { display: flex; justify-content: space-between; align-items: center; gap: 25px; }
.clone-control { display: grid; grid-template-columns: minmax(160px, 220px) auto; gap: 9px; }

.table-panel { padding: 0; overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 14px 18px; text-align: left; vertical-align: middle; border-bottom: 1px solid #edf1f3; font-size: 13px; }
.data-table th { background: #f8fafb; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.data-table .actions-column, .data-table .actions-cell { width: 300px; min-width: 300px; text-align: left; }
.data-table td strong, .data-table td small { display: block; }
.data-table td small { margin-top: 3px; color: var(--muted); }
.data-table tr:last-child td { border-bottom: 0; }
.client-empty-state { display: flex; align-items: center; gap: 14px; min-height: 72px; padding: 16px 18px; border-radius: 10px; background: #f7fafb; }
.client-empty-mark { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; background: var(--brand-orange); box-shadow: 0 0 0 5px rgba(241,135,0,.11); }
.client-empty-state div { display: grid; gap: 3px; }
.client-empty-state strong { color: var(--brand-blue-dark); font-size: 13px; }
.client-empty-state p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.client-registration-panel .panel-heading { padding-bottom: 18px; border-bottom: 1px solid #edf1f3; }
.client-identity-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
.optional-label { margin-left: 5px; color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.client-form-section { margin-top: 24px; padding-top: 21px; border-top: 1px solid #edf1f3; }
.client-form-section legend { padding: 0; color: var(--brand-blue-dark); font-size: 13px; font-weight: 700; }
.client-form-section > p { margin: 5px 0 12px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.client-scope-option { min-height: 66px; align-items: center; }
.client-scope-option input { margin-top: 0; }
.client-certificate-field { margin-top: 28px; padding-top: 27px; border-top: 1px solid #edf1f3; }
.client-certificate-field textarea { min-height: 170px; margin-top: 4px; font-family: Consolas, "Courier New", monospace; font-size: 12px; line-height: 1.5; }
.client-form-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 18px; padding-top: 18px; border-top: 1px solid #edf1f3; }
.client-form-actions p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.client-form-actions .button { min-width: 175px; }
.table-actions { display: flex; align-items: center; justify-content: flex-start; gap: 8px; white-space: nowrap; }
.status-pill { display: inline-block; padding: 5px 8px; border-radius: 999px; background: #eef2f4; color: var(--muted); font-size: 11px; font-weight: 750; white-space: nowrap; }
.status-pill.success { background: #e5f5ec; color: #12633d; }
.status-pill.draft { background: #fff3df; color: #8d5200; }
.status-pill.error { background: #fff1ef; color: var(--danger); }
.list-panel .table-panel { overflow-x: auto; }
.client-table .actions-column, .client-table .actions-cell { width: 500px; min-width: 500px; }
.client-direct-actions { flex-wrap: nowrap; gap: 7px; }
.client-action { min-height: 36px; padding: 7px 13px; border: 1px solid transparent; border-radius: 9px; box-shadow: none; }
.client-action.standard { background: #eaf4f8; color: var(--brand-blue); border-color: #d7eaf2; }
.client-action.standard:hover:not(:disabled) { background: #dceef6; border-color: #b8d9e7; }
.client-action.warning { background: #fff8ed; color: var(--warning); border-color: #f3d6aa; }
.client-action.warning:hover:not(:disabled) { background: #fff0d8; border-color: #e8bd7b; }
.client-action.positive { background: #edf8f2; color: #12633d; border-color: #b8dec9; }
.client-action.positive:hover:not(:disabled) { background: #dff2e8; border-color: #91c9aa; }
.client-action.destructive { background: #fff1ef; color: var(--danger); border-color: #efc0bb; }
.client-action.destructive:hover:not(:disabled) { background: #ffe5e1; border-color: #e5a49d; }
.client-action:focus-visible { outline: 3px solid rgba(7,92,135,.18); outline-offset: 2px; }
.client-action-divider { width: 1px; height: 24px; margin: 0 2px; align-self: center; background: var(--border); }
.certificate-table .actions-cell { width: 190px; min-width: 190px; }
.certificate-table td small { max-width: 310px; overflow-wrap: anywhere; }
.certificate-renewal-form .client-certificate-field { margin-top: 22px; }

.app-modal { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 40px); margin: auto; padding: 0; border: 0; border-radius: 15px; background: white; color: var(--ink); box-shadow: 0 28px 80px rgba(6,61,92,.28); }
.app-modal[open] { display: flex; flex-direction: column; }
.app-modal.modal-wide { width: min(1040px, calc(100vw - 32px)); }
.app-modal.modal-small { width: min(520px, calc(100vw - 32px)); }
.app-modal::backdrop { background: rgba(6,35,52,.55); backdrop-filter: blur(2px); }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 22px 24px 18px; border-bottom: 1px solid var(--border); }
.modal-heading h2 { margin: 0; font-size: 21px; }
.modal-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.modal-close { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; border: 1px solid var(--border); border-radius: 8px; background: white; color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; }
.modal-close:hover { border-color: #abc4d1; background: #f8fafb; color: var(--brand-blue-dark); }
.modal-content { min-height: 0; padding: 22px 24px; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 16px 24px; border-top: 1px solid var(--border); background: #f8fafb; }
.modal-form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; padding-top: 18px; border-top: 1px solid #edf1f3; }
.modal-form-actions.split-actions { align-items: center; justify-content: space-between; }
.modal-form-actions p { max-width: 520px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.modal-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.confirmation-content { display: grid; gap: 8px; padding: 15px; border-left: 3px solid var(--brand-orange); border-radius: 0 8px 8px 0; background: #fffaf3; }
.confirmation-content.destructive { border-left-color: var(--danger); background: #fff5f3; }
.confirmation-content strong { color: var(--brand-blue-dark); font-size: 14px; overflow-wrap: anywhere; }
.confirmation-content p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.split-layout { display: grid; grid-template-columns: .8fr 1.2fr; gap: 20px; align-items: start; }
.monitoring-panel { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(300px, 400px) auto; align-items: center; gap: 28px; padding: 20px 26px; }
.monitoring-panel .panel-heading { margin: 0; }
.monitoring-panel > form { display: contents; }
.monitoring-settings { display: contents; }
.monitoring-interval { width: auto; }
.monitoring-panel .button { align-self: center; min-height: 44px; white-space: nowrap; }
.resource-list { display: grid; gap: 8px; }
.resource-item { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; padding: 12px; border: 1px solid var(--border); border-radius: 9px; background: white; color: var(--ink); text-align: left; cursor: pointer; }
.resource-item:hover, .resource-item.selected { border-color: #8fc3d9; background: #f2f9fc; }
.resource-item > span:nth-child(2) { display: grid; gap: 3px; }
.resource-item strong { font-size: 13px; }
.resource-item small { color: var(--muted); font-size: 11px; }
.health-detail { display: flex; align-items: flex-start; gap: 12px; margin-top: 20px; padding: 14px; background: #f8fafb; border-radius: 9px; }
.health-detail div { display: grid; gap: 4px; }
.health-detail small { color: var(--muted); }

.license-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.license-card { display: grid; align-content: start; gap: 18px; }
.license-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.license-heading h2 { margin: 0; }
.detail-list { margin: 0; display: grid; gap: 0; }
.detail-list div { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-top: 1px solid #edf1f3; }
.detail-list dt { color: var(--muted); font-size: 12px; }
.detail-list dd { margin: 0; font-size: 13px; font-weight: 700; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: linear-gradient(145deg, var(--brand-sky), var(--background) 48%, #fff8ed); }
.login-shell { position: relative; }
.login-language { position: absolute; top: 24px; right: 28px; }
.login-card { width: min(100%, 470px); padding: 35px; background: white; border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 24px 60px rgba(6,61,92,.14); }
.login-brand { margin-bottom: 24px; color: var(--brand-blue-dark); }
.login-card h1 { font-size: 30px; }
.login-card .stack-form { margin-top: 24px; }
.login-help { margin: 20px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.app-footer { display: flex; justify-content: space-between; max-width: 1240px; margin: auto; padding: 22px 28px 35px; color: var(--muted); border-top: 1px solid var(--border); font-size: 12px; }

@media (max-width: 850px) {
    .header-content, .admin-nav > div, .page-shell { padding-left: 18px; padding-right: 18px; }
    .brand-product, .brand-divider, .account-area > span { display: none; }
    .page-heading { align-items: stretch; flex-direction: column; }
    .metric-grid, .license-grid, .split-layout { grid-template-columns: 1fr; }
    .form-grid, .option-grid { grid-template-columns: 1fr; }
    .client-identity-grid { grid-template-columns: 1fr; }
    .client-form-actions { align-items: stretch; flex-direction: column; }
    .modal-grid { grid-template-columns: 1fr; }
    .modal-form-actions.split-actions { align-items: stretch; flex-direction: column; }
    .client-form-actions .button { width: 100%; }
    .reader-selector { grid-template-columns: 1fr; }
    .credential-panel { align-items: stretch; flex-direction: column; }
    .monitoring-panel { display: flex; align-items: stretch; flex-direction: column; }
    .monitoring-settings { display: flex; align-items: stretch; flex-direction: column; }
    .monitoring-panel .button { align-self: stretch; }
    .monitoring-interval { width: auto; }
    .full-width { grid-column: auto; }
    .clone-panel, .action-bar, .app-footer { align-items: stretch; flex-direction: column; }
    .clone-control { grid-template-columns: 1fr; }
    .table-panel { overflow-x: auto; }
    .data-table { min-width: 680px; }
    .client-table { min-width: 1080px; }
    .client-action-divider { display: none; }
}
