/* ============ EMS design system (driven by CSS variables set from branding settings) ============ */
html { font-size: var(--fs); }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, .font-heading { font-family: var(--font-h); }
* { box-sizing: border-box; }
a { color: rgb(var(--c-primary)); }
:focus-visible { outline: 3px solid rgb(var(--c-primary) / .45); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: #fff; padding: 8px 12px; border-radius: 6px; }
.skip-link:focus { left: 8px; }
.boot-loader { display: grid; place-items: center; height: 100vh; font-size: 28px; color: rgb(var(--c-primary)); }
#preview-banner { background: rgb(var(--c-accent)); color: #111; text-align: center; padding: 6px; font-weight: 600; font-size: 13px; position: sticky; top: 0; z-index: 60; }

.surface { background: var(--surface); }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid rgb(148 163 184 / .18); }
.muted { color: rgb(100 116 139); }
html.dark .muted { color: rgb(148 163 184); }
.divider { border-color: rgb(148 163 184 / .25); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .55rem 1rem; border-radius: var(--radius); font-weight: 600; font-size: .9rem; border: 1px solid transparent; cursor: pointer; transition: all .15s; white-space: nowrap; text-decoration: none; line-height: 1.2; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-primary { background: rgb(var(--c-primary)); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-outline .btn-primary { background: transparent; color: rgb(var(--c-primary)); border-color: rgb(var(--c-primary)); }
.btn-soft .btn-primary { background: rgb(var(--c-primary) / .12); color: rgb(var(--c-primary)); }
.btn-secondary { background: transparent; color: var(--text); border-color: rgb(148 163 184 / .5); }
.btn-secondary:hover:not(:disabled) { background: rgb(148 163 184 / .12); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-success { background: #16a34a; color: #fff; }
.btn-warning { background: #d97706; color: #fff; }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: rgb(148 163 184 / .14); }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 999px; background: transparent; border: 0; color: inherit; cursor: pointer; position: relative; }
.icon-btn:hover { background: rgb(148 163 184 / .15); }

/* Forms */
.form-label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .3rem; }
.form-label .req { color: #dc2626; }
.input, .select, .textarea { width: 100%; padding: .55rem .75rem; border: 1px solid rgb(148 163 184 / .55); border-radius: calc(var(--radius) * .8); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: rgb(var(--c-primary)); box-shadow: 0 0 0 3px rgb(var(--c-primary) / .18); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: #dc2626; }
.field-error { color: #dc2626; font-size: .75rem; margin-top: .25rem; }
.field-help { font-size: .75rem; margin-top: .25rem; color: rgb(100 116 139); }
.field-ok { color: #16a34a; font-size: .75rem; margin-top: .25rem; }
.input[readonly] { background: rgb(148 163 184 / .1); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 700; text-transform: capitalize; white-space: nowrap; }
.b-pending, .b-pending_manager, .b-booking_pending, .b-queued, .b-sending, .b-invited, .b-probation { background: #fef3c7; color: #92400e; }
.b-approved, .b-active, .b-generated, .b-valid, .b-accepted, .b-delivered, .b-booked, .b-ticket_issued, .b-published { background: #dcfce7; color: #166534; }
.b-rejected, .b-failed, .b-bounced, .b-revoked, .b-suspended, .b-terminated, .b-deactivated { background: #fee2e2; color: #991b1b; }
.b-info_requested, .b-not_configured, .b-on_leave { background: #dbeafe; color: #1e40af; }
.b-cancelled, .b-not_started, .b-draft, .b-archived, .b-resigned, .b-captured_dev { background: #e2e8f0; color: #334155; }
html.dark .badge { filter: brightness(.9) saturate(1.1); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.data th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: rgb(100 116 139); padding: .6rem .75rem; border-bottom: 1px solid rgb(148 163 184 / .3); white-space: nowrap; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: rgb(var(--c-primary)); }
table.data td { padding: .65rem .75rem; border-bottom: 1px solid rgb(148 163 184 / .16); vertical-align: middle; }
table.data tbody tr:hover { background: rgb(var(--c-primary) / .04); }
table.data tbody tr.clickable { cursor: pointer; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 260px; flex-shrink: 0; display: flex; flex-direction: column; transition: width .2s, transform .2s; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40; }
.sidebar-dark .sidebar { background: rgb(var(--c-secondary)); color: #cbd5e1; }
.sidebar-light .sidebar { background: var(--surface); color: var(--text); border-right: 1px solid rgb(148 163 184 / .25); }
.sidebar-brand .sidebar { background: rgb(var(--c-primary)); color: #e0e7ff; }
.sidebar .brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.1rem; font-weight: 700; font-size: 1.02rem; color: #fff; min-height: 64px; }
.sidebar-light .sidebar .brand { color: var(--text); }
.sidebar .brand img { max-height: 34px; max-width: 150px; object-fit: contain; }
.sidebar nav { padding: .5rem .6rem 1rem; flex: 1; }
.sidebar .nav-group { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; opacity: .55; padding: .9rem .7rem .35rem; }
.sidebar a.nav-link { display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; border-radius: calc(var(--radius) * .8); color: inherit; text-decoration: none; font-size: .88rem; font-weight: 500; }
.sidebar a.nav-link i { width: 18px; text-align: center; opacity: .85; }
.sidebar a.nav-link:hover { background: rgb(255 255 255 / .08); }
.sidebar-light .sidebar a.nav-link:hover { background: rgb(148 163 184 / .14); }
.sidebar a.nav-link.active { background: rgb(var(--c-primary)); color: #fff; }
.sidebar-brand .sidebar a.nav-link.active { background: rgb(255 255 255 / .2); }
.sidebar .nav-count { margin-left: auto; background: rgb(var(--c-accent)); color: #111; border-radius: 999px; font-size: .68rem; padding: 0 .45rem; font-weight: 700; }
.layout.collapsed .sidebar { width: 72px; }
.layout.collapsed .sidebar .label, .layout.collapsed .sidebar .nav-group, .layout.collapsed .sidebar .nav-count, .layout.collapsed .sidebar .brand span { display: none; }
.layout.collapsed .sidebar a.nav-link { justify-content: center; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 64px; display: flex; align-items: center; gap: .5rem; padding: 0 1.25rem; background: var(--surface); border-bottom: 1px solid rgb(148 163 184 / .22); position: sticky; top: 0; z-index: 30; }
.content { padding: 1.5rem; max-width: 1400px; width: 100%; margin: 0 auto; }
.page-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.backdrop { display: none; }
@media (max-width: 1023px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); }
  .layout.mobile-open .sidebar { transform: none; }
  .layout.mobile-open .backdrop { display: block; position: fixed; inset: 0; background: rgb(0 0 0 / .45); z-index: 35; }
  .layout.collapsed .sidebar { width: 260px; }
  .layout.collapsed .sidebar .label, .layout.collapsed .sidebar .nav-group, .layout.collapsed .sidebar .brand span { display: initial; }
  .content { padding: 1rem; }
}

/* Stat cards */
.stat { padding: 1.1rem 1.2rem; display: flex; gap: 1rem; align-items: center; }
.stat .ico { width: 46px; height: 46px; border-radius: calc(var(--radius) * 1.1); display: grid; place-items: center; font-size: 1.15rem; flex-shrink: 0; }
.stat .val { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { font-size: .78rem; color: rgb(100 116 139); font-weight: 500; }

/* Dropdown / menus */
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border-radius: var(--radius); box-shadow: 0 12px 32px -8px rgb(15 23 42 / .3); border: 1px solid rgb(148 163 184 / .25); z-index: 50; overflow: hidden; }
.dropdown a, .dropdown button { display: flex; width: 100%; gap: .6rem; align-items: center; padding: .6rem .9rem; font-size: .86rem; color: var(--text); text-decoration: none; background: none; border: 0; cursor: pointer; text-align: left; }
.dropdown a:hover, .dropdown button:hover { background: rgb(148 163 184 / .12); }
.notif-dot { position: absolute; top: 4px; right: 4px; background: #dc2626; color: #fff; font-size: .62rem; min-width: 17px; height: 17px; border-radius: 999px; display: grid; place-items: center; font-weight: 700; padding: 0 4px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgb(15 23 42 / .55); display: grid; place-items: center; z-index: 80; padding: 1rem; animation: fade .12s; }
.modal { background: var(--surface); color: var(--text); border-radius: calc(var(--radius) * 1.2); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; box-shadow: 0 25px 60px -15px rgb(0 0 0 / .45); }
.modal.lg { max-width: 860px; }
.modal.xl { max-width: 1100px; }
.modal-head { padding: 1.1rem 1.3rem; border-bottom: 1px solid rgb(148 163 184 / .22); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1.3rem; }
.modal-foot { padding: 1rem 1.3rem; border-top: 1px solid rgb(148 163 184 / .22); display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0 } }

/* Toasts */
#toast-root { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 90; max-width: min(420px, calc(100vw - 2rem)); }
.toast { padding: .8rem 1rem; border-radius: var(--radius); color: #fff; font-size: .88rem; box-shadow: 0 10px 25px -5px rgb(0 0 0 / .3); display: flex; gap: .6rem; align-items: flex-start; animation: slide .2s; }
.toast.success { background: #15803d; } .toast.error { background: #b91c1c; } .toast.info { background: #1e40af; } .toast.warning { background: #b45309; }
@keyframes slide { from { transform: translateY(12px); opacity: 0 } }

/* Misc */
.empty { text-align: center; padding: 2.5rem 1rem; color: rgb(100 116 139); }
.empty i { font-size: 2rem; opacity: .45; margin-bottom: .6rem; display: block; }
.skeleton { background: linear-gradient(90deg, rgb(148 163 184 / .15), rgb(148 163 184 / .3), rgb(148 163 184 / .15)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; }
@keyframes sk { to { background-position: -200% 0 } }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid rgb(148 163 184 / .3); overflow-x: auto; }
.tab { padding: .6rem 1rem; border: 0; background: none; color: rgb(100 116 139); font-weight: 600; font-size: .86rem; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: rgb(var(--c-primary)); border-bottom-color: rgb(var(--c-primary)); }
.tab .cnt { background: rgb(148 163 184 / .25); border-radius: 999px; padding: 0 .45rem; font-size: .7rem; margin-left: .3rem; }
.dl { display: grid; grid-template-columns: minmax(130px, 38%) 1fr; gap: .55rem 1rem; font-size: .88rem; }
.dl dt { color: rgb(100 116 139); font-weight: 500; }
.dl dd { margin: 0; font-weight: 500; word-break: break-word; }
.timeline { border-left: 2px solid rgb(148 163 184 / .35); margin-left: .5rem; padding-left: 1rem; }
.timeline .item { position: relative; padding-bottom: 1rem; font-size: .85rem; }
.timeline .item::before { content: ''; position: absolute; left: -1.38rem; top: .3rem; width: .7rem; height: .7rem; border-radius: 999px; background: rgb(var(--c-primary)); border: 2px solid var(--surface); }
.avatar { border-radius: 999px; object-fit: cover; background: rgb(var(--c-primary) / .15); color: rgb(var(--c-primary)); display: inline-grid; place-items: center; font-weight: 700; flex-shrink: 0; overflow: hidden; }
.auth-bg { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .auth-bg { grid-template-columns: 1.05fr 1fr; } }
.auth-side { background: linear-gradient(135deg, rgb(var(--c-primary)), rgb(var(--c-secondary))); color: #fff; padding: 3rem; display: none; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
@media (min-width: 1024px) { .auth-side { display: flex; } }
.auth-side::after { content: ''; position: absolute; width: 520px; height: 520px; border-radius: 999px; background: rgb(255 255 255 / .06); right: -160px; bottom: -160px; }
.swatch { width: 42px; height: 38px; border-radius: 8px; border: 1px solid rgb(148 163 184 / .5); padding: 0; cursor: pointer; }
.kbd { font-family: ui-monospace, monospace; font-size: .75rem; background: rgb(148 163 184 / .2); border-radius: 4px; padding: 0 .3rem; }
.prose-sm p { margin: .4rem 0; } .prose-sm ul { list-style: disc; padding-left: 1.2rem; }
.chart-box { position: relative; height: 260px; }
.verify-valid { border-top: 6px solid #16a34a; } .verify-revoked { border-top: 6px solid #dc2626; }
@media print { .sidebar, .topbar, #toast-root { display: none !important; } }
