:root {
    color-scheme: light;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-soft: #f8f9fc;
    --text: #172033;
    --muted: #697386;
    --line: #e4e8f0;
    --primary: #635bff;
    --primary-dark: #5048e5;
    --primary-soft: #eeedff;
    --success: #18875d;
    --danger: #c7394f;
    --shadow: 0 18px 48px rgba(33, 43, 74, .09);
    --radius: 18px;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 10% -10%, #e9e7ff 0, transparent 30rem), var(--bg); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.icon { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }

.boot-loader, .content-loader { display: flex; min-height: 18rem; align-items: center; justify-content: center; gap: .8rem; color: var(--muted); }
.boot-loader { min-height: 100vh; }
.spinner { display: inline-block; width: 1.3rem; height: 1.3rem; border: 2px solid #d9dcef; border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner--small { width: 1rem; height: 1rem; border-color: rgba(255,255,255,.4); border-top-color: white; vertical-align: -.15rem; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; }
.login-card { width: min(100%, 430px); padding: clamp(1.6rem, 5vw, 2.5rem); background: rgba(255,255,255,.94); border: 1px solid rgba(255,255,255,.9); border-radius: 24px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.login-logo { display: grid; place-items: center; width: 3.25rem; height: 3.25rem; margin-bottom: 1.4rem; color: white; background: var(--primary); border-radius: 15px; box-shadow: 0 10px 25px rgba(99,91,255,.28); }
.login-logo .icon { width: 1.55rem; height: 1.55rem; }
.login-card h1 { margin: 0 0 .45rem; font-size: 1.75rem; letter-spacing: -.035em; }
.login-card > p { margin: 0 0 1.7rem; }
.login-card label { display: block; margin: 1rem 0 .45rem; font-size: .875rem; font-weight: 650; }
.login-card input { width: 100%; padding: .82rem .95rem; color: var(--text); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 11px; outline: none; transition: border-color .18s, box-shadow .18s, background .18s; }
.login-card input:focus { background: white; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-error { margin: 1rem 0 .25rem; padding: .75rem .85rem; color: #9d263b; background: #fff0f2; border: 1px solid #ffd6dc; border-radius: 10px; font-size: .875rem; }
.form-error[hidden] { display: none; }

.button { min-height: 2.6rem; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .65rem 1rem; border: 0; border-radius: 10px; font-weight: 650; cursor: pointer; transition: transform .15s, background .15s, opacity .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: default; opacity: .48; }
.button--primary { color: white; background: var(--primary); }
.button--primary:hover:not(:disabled) { background: var(--primary-dark); }
.button--wide { width: 100%; margin-top: 1.4rem; }
.button--ghost { color: #454e62; background: white; border: 1px solid var(--line); }
.button--ghost:hover:not(:disabled) { background: var(--surface-soft); }

.topbar { position: sticky; z-index: 10; top: 0; background: rgba(255,255,255,.82); border-bottom: 1px solid rgba(218,223,234,.8); backdrop-filter: blur(16px); }
.topbar__inner { width: min(100% - 2rem, 920px); height: 4.25rem; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; font-weight: 760; letter-spacing: -.02em; }
.brand__icon { width: 2rem; height: 2rem; display: grid; place-items: center; color: white; background: var(--primary); border-radius: 9px; }
.brand__icon .icon { width: 1.05rem; height: 1.05rem; }
.topbar__actions { display: flex; align-items: center; gap: 1rem; }
.user-name { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; color: var(--muted); }
.icon-button { display: grid; place-items: center; width: 2.35rem; height: 2.35rem; color: var(--muted); background: transparent; border: 0; border-radius: 9px; cursor: pointer; }
.icon-button:hover { color: var(--text); background: var(--surface-soft); }
.socket-status { display: inline-flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .78rem; white-space: nowrap; }
.socket-status__dot { width: .48rem; height: .48rem; background: #9aa3b2; border-radius: 50%; }
.socket-status--connected .socket-status__dot { background: #31b782; box-shadow: 0 0 0 4px rgba(49,183,130,.12); }
.socket-status--reconnecting .socket-status__dot { background: #e6a52e; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.page-content { width: min(100% - 2rem, 920px); margin: 0 auto; padding: 3rem 0 5rem; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-heading h1 { display: flex; align-items: center; gap: .7rem; margin: .25rem 0 0; font-size: clamp(1.75rem, 4vw, 2.25rem); letter-spacing: -.045em; }
.eyebrow { color: var(--primary); font-size: .75rem; font-weight: 750; text-transform: uppercase; letter-spacing: .11em; }
.count-badge { min-width: 1.7rem; height: 1.7rem; padding: 0 .45rem; display: inline-grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 99px; font-size: .85rem; letter-spacing: 0; }
.notification-list { display: grid; gap: .7rem; }
.notification-card { position: relative; display: grid; grid-template-columns: .6rem 1fr auto; align-items: center; gap: .85rem; min-width: 0; padding: 1.2rem 1.25rem; text-decoration: none; background: rgba(255,255,255,.91); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 2px 8px rgba(28,38,65,.025); transition: transform .18s, box-shadow .18s, border-color .18s; overflow: hidden; }
.notification-card:hover { z-index: 1; transform: translateY(-2px); border-color: #d3d4f8; box-shadow: 0 12px 30px rgba(36,43,87,.08); }
.notification-card--unread { background: linear-gradient(100deg, #f6f5ff, white 42%); border-color: #dbd8ff; }
.notification-card--unread h2 { font-weight: 750; }
.notification-card--new { animation: arrive .65s ease both; }
@keyframes arrive { from { opacity: 0; transform: translateY(-12px); background: #ebe9ff; } }
.unread-dot { width: .55rem; height: .55rem; background: transparent; border-radius: 50%; }
.notification-card--unread .unread-dot { background: var(--primary); box-shadow: 0 0 0 4px rgba(99,91,255,.1); }
.notification-card__content { min-width: 0; }
.notification-card__top { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.notification-card h2 { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; font-weight: 650; }
.notification-card time { flex: 0 0 auto; color: var(--muted); font-size: .76rem; }
.notification-card p { margin: .35rem 0 .7rem; overflow: hidden; color: var(--muted); font-size: .9rem; text-overflow: ellipsis; white-space: nowrap; }
.notification-tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.type-pill { display: inline-flex; padding: .25rem .52rem; color: #566073; background: #f0f2f6; border-radius: 6px; font-size: .7rem; font-weight: 680; }
.type-pill--order { color: #79520f; background: #fff3d9; }
.type-pill--payment { color: #0f7252; background: #dff7ed; }
.type-pill--security { color: #9f3043; background: #ffeaed; }
.type-pill--system { color: #4f49b8; background: #eae9ff; }
.type-pill--phone { color: #17634b; background: #def5eb; }
.type-pill--card { color: #79520f; background: #fff3d9; }
.source-pill { display: inline-flex; padding: .25rem .52rem; color: #526077; background: #edf1f7; border-radius: 6px; font-size: .7rem; font-weight: 620; }
.card-chevron { color: #a1a8b5; }
.card-chevron .icon { width: 1rem; height: 1rem; }

.empty-state { display: grid; justify-items: center; padding: 4rem 1.5rem; text-align: center; background: rgba(255,255,255,.8); border: 1px dashed #d5dae5; border-radius: var(--radius); }
.empty-state__icon { display: grid; place-items: center; width: 3.5rem; height: 3.5rem; color: var(--primary); background: var(--primary-soft); border-radius: 50%; }
.empty-state h2 { margin: 1rem 0 .4rem; font-size: 1.15rem; }
.empty-state p { max-width: 26rem; margin: 0; color: var(--muted); }
.empty-state--error .button { margin-top: 1.25rem; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 1.5rem; color: var(--muted); font-size: .85rem; }

.page-content--detail { max-width: 760px; }
.back-link { display: inline-flex; align-items: center; gap: .45rem; margin-bottom: 1.2rem; color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 620; }
.back-link:hover { color: var(--primary); }
.back-link .icon { width: 1rem; }
.detail-card { padding: clamp(1.4rem, 5vw, 2.5rem); background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.detail-meta { display: flex; align-items: center; gap: .8rem; color: var(--muted); font-size: .78rem; }
.read-status::before { content: '•'; margin-right: .8rem; }
.detail-card h1 { margin: 1.4rem 0 1rem; font-size: clamp(1.65rem, 4vw, 2.25rem); line-height: 1.15; letter-spacing: -.04em; }
.detail-body { margin: 0; color: #3d475a; font-size: 1.02rem; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.metadata { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.metadata h2 { margin: 0 0 1rem; font-size: .95rem; }
.metadata dl { margin: 0; display: grid; gap: .55rem; }
.metadata-row { display: grid; grid-template-columns: minmax(7rem, .4fr) 1fr; gap: 1rem; font-size: .85rem; }
.metadata dt { color: var(--muted); overflow-wrap: anywhere; }
.metadata dd { margin: 0; overflow-wrap: anywhere; }
.copyable-value { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-width: 0; }
.copyable-value > span { min-width: 0; overflow-wrap: anywhere; }
.copy-button { flex: 0 0 auto; display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0; color: var(--muted); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; transition: color .15s, background .15s, border-color .15s; }
.copy-button:hover { color: var(--primary); background: var(--primary-soft); border-color: #d6d2ff; }
.copy-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.copy-button .icon { width: 1rem; height: 1rem; }
.clipboard-fallback { position: fixed; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.toast-region { position: fixed; z-index: 30; right: 1.2rem; bottom: 1.2rem; display: grid; gap: .6rem; pointer-events: none; }
.toast { max-width: min(22rem, calc(100vw - 2rem)); padding: .85rem 1rem; color: white; background: #242b3b; border-radius: 11px; box-shadow: 0 15px 35px rgba(21,28,45,.22); opacity: 0; transform: translateY(10px); transition: opacity .22s, transform .22s; }
.toast--visible { opacity: 1; transform: translateY(0); }
.toast--error { background: var(--danger); }

@media (max-width: 640px) {
    .topbar__inner, .page-content { width: min(100% - 1.2rem, 920px); }
    .topbar__actions { gap: .45rem; }
    .user-name { display: none; }
    .socket-status > span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
    .page-content { padding-top: 2rem; }
    .page-heading { align-items: center; }
    .page-heading .button { width: 2.65rem; padding: 0; font-size: 0; }
    .page-heading .button .icon { width: 1.1rem; }
    .notification-card { grid-template-columns: .45rem 1fr auto; gap: .6rem; padding: 1rem .85rem; }
    .notification-card__top { display: block; }
    .notification-card time { display: block; margin-top: .25rem; }
    .detail-meta { flex-wrap: wrap; }
    .metadata-row { grid-template-columns: 1fr; gap: .15rem; }
}

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