:root {
  --bg: #f3f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #152235;
  --muted: #64748b;
  --line: #dce3eb;
  --primary: #173a63;
  --primary-2: #24578e;
  --danger: #9f2d2d;
  --success: #16724a;
  --shadow: 0 18px 45px rgba(16, 35, 56, .10);
  --radius: 18px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.app-shell { min-height: 100vh; }
.topbar { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 28px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--primary); color: white; font-weight: 800; letter-spacing: -.04em; }
.brand strong { display: block; font-size: 17px; }
.brand span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.user-label { color: var(--muted); font-size: 13px; max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main { width: min(1180px, calc(100% - 32px)); margin: 28px auto 60px; }
.center-card { width: min(520px, 100%); margin: 11vh auto 0; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 46px 32px; box-shadow: var(--shadow); }
.center-card h1 { margin: 12px 0 8px; font-size: 28px; }
.center-card p { color: var(--muted); line-height: 1.55; }
.lock-icon { width: 72px; height: 72px; margin: 0 auto; border-radius: 22px; display: grid; place-items: center; background: #e9eff6; color: var(--primary); font-size: 36px; }
.help { font-size: 12px; margin-top: 18px !important; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; margin: 0 auto 14px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn { border: 1px solid transparent; border-radius: 11px; padding: 10px 14px; font-weight: 700; transition: .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-2); }
.btn-secondary { background: #e9eff6; color: var(--primary); border-color: #d4dfeb; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-danger { background: #fff2f2; color: var(--danger); border-color: #f0cccc; }
.btn-mini { padding: 8px 10px; font-size: 12px; background: var(--surface-2); border-color: var(--line); color: var(--primary); white-space: nowrap; }
.tabs { display: flex; gap: 8px; margin-bottom: 20px; overflow-x: auto; padding-bottom: 3px; }
.tab { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 9px 15px; font-weight: 700; white-space: nowrap; }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tab-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: 0 8px 25px rgba(17, 35, 55, .05); }
.toolbar, .section-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 20px; }
.section-head h2 { margin: 0; font-size: 21px; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.search-wrap { display: grid; grid-template-columns: minmax(240px, 1fr) 190px; gap: 10px; flex: 1; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; background: var(--surface); color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: #8aa6c4; box-shadow: 0 0 0 3px rgba(36, 87, 142, .09); }
.credential-list { display: grid; gap: 9px; }
.credential-row { display: grid; grid-template-columns: minmax(220px, 1.5fr) minmax(110px, .7fr) minmax(110px, .6fr) auto; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; background: var(--surface); }
.credential-row:hover { border-color: #bdcad8; background: #fbfdff; }
.service-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.service-meta { min-width: 0; }
.service-icon { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; background: #eef3f8; border: 1px solid #dbe5ef; overflow: hidden; color: var(--primary); font-weight: 800; font-size: 12px; text-transform: uppercase; }
.service-icon-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.service-icon.service-icon-fallback { color: white; border-color: transparent; }
.service-icon.palette-1.service-icon-fallback { background: linear-gradient(135deg, #24578e, #173a63); }
.service-icon.palette-2.service-icon-fallback { background: linear-gradient(135deg, #0f766e, #155e75); }
.service-icon.palette-3.service-icon-fallback { background: linear-gradient(135deg, #8b5cf6, #5b21b6); }
.service-icon.palette-4.service-icon-fallback { background: linear-gradient(135deg, #f97316, #c2410c); }
.service-icon.palette-5.service-icon-fallback { background: linear-gradient(135deg, #ec4899, #be185d); }
.service-icon.palette-6.service-icon-fallback { background: linear-gradient(135deg, #65a30d, #3f6212); }
.service-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.service-url { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-flex; width: fit-content; align-items: center; border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 5px 9px; color: var(--muted); font-size: 12px; }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 6px; }
.stack-list, .audit-list { display: grid; gap: 9px; }
.stack-item, .audit-item { border: 1px solid var(--line); border-radius: 13px; padding: 13px 14px; background: var(--surface-2); }
.stack-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack-item strong { display: block; }
.stack-item small, .audit-item small { color: var(--muted); }
.audit-item { display: grid; grid-template-columns: 160px 1fr auto; gap: 12px; align-items: baseline; font-size: 13px; }
.access-grid { display: grid; gap: 16px; }
.access-card { border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
.access-card-head { display: flex; justify-content: space-between; align-items: center; padding: 13px 15px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.access-card-head strong { display: block; }
.access-card-head small { color: var(--muted); }
.access-users { padding: 0 15px; }
.access-user { display: grid; grid-template-columns: minmax(180px, 1fr) 180px; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.access-user:last-child { border-bottom: 0; }
.access-user span { overflow: hidden; text-overflow: ellipsis; }
.dialog { width: min(620px, calc(100% - 24px)); max-height: calc(100vh - 32px); overflow: auto; border: 0; border-radius: 20px; padding: 0; box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(9, 21, 34, .46); backdrop-filter: blur(2px); }
.dialog form, .dialog > div:not(.dialog-head) { padding-left: 22px; padding-right: 22px; }
.dialog form { padding-bottom: 22px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px 12px; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.dialog-head h2 { margin: 0; font-size: 21px; }
.icon-btn { width: 36px; height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; font-size: 22px; line-height: 1; }
.dialog label { display: block; font-size: 13px; font-weight: 700; margin: 12px 0; }
.dialog label input, .dialog label select, .dialog label textarea { margin-top: 6px; font-weight: 400; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 16px 22px 22px; }
.input-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 6px; }
.input-row input { margin-top: 0 !important; }
.small-dialog { width: min(480px, calc(100% - 24px)); }
.secret-fields { display: grid; gap: 12px; padding-bottom: 8px; }
.secret-field { border: 1px solid var(--line); border-radius: 13px; padding: 11px 12px; background: var(--surface-2); }
.secret-field .label { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 5px; }
.secret-value-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
.secret-value { overflow-wrap: anywhere; white-space: pre-wrap; }
.muted { color: var(--muted); font-weight: 400; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 100; max-width: min(420px, calc(100% - 36px)); background: #162638; color: white; border-radius: 12px; padding: 12px 15px; box-shadow: var(--shadow); font-size: 13px; }
.toast.error { background: #7d2929; }
@media (max-width: 760px) {
  .topbar { padding: 10px 14px; }
  .brand span, .user-label { display: none; }
  .main { width: min(100% - 20px, 1180px); margin-top: 16px; }
  .tab-panel { padding: 14px; border-radius: 14px; }
  .toolbar, .section-head { align-items: stretch; flex-direction: column; }
  .toolbar > .btn, .section-head > .btn { width: 100%; }
  .search-wrap { grid-template-columns: 1fr; width: 100%; }
  .credential-row { grid-template-columns: 1fr auto; gap: 8px; }
  .credential-row .service-main, .credential-row .service-url, .credential-row .pill { grid-column: 1; }
  .row-actions { grid-column: 2; grid-row: 1 / span 3; flex-direction: column; }
  .access-user { grid-template-columns: 1fr; }
  .audit-item { grid-template-columns: 1fr; gap: 4px; }
  .center-card { margin-top: 5vh; padding: 34px 20px; }
}
