:root {
    --color-primary: #2457d6;
    --color-primary-hover: #1d46b3;
    --color-primary-soft: #eef3ff;
    --color-ink: #182230;
    --color-muted: #667085;
    --color-subtle: #98a2b3;
    --color-border: #e4e7ec;
    --color-border-strong: #d0d5dd;
    --color-surface: #ffffff;
    --color-background: #f6f8fb;
    --color-success: #087a55;
    --color-success-soft: #ecfdf3;
    --color-danger: #b42318;
    --color-danger-soft: #fef3f2;
    --color-nav: #101828;
    --shadow-card: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 28px rgba(16, 24, 40, .05);
    --shadow-dialog: -20px 0 70px rgba(16, 24, 40, .18);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --content-width: 1480px;
    --ease: 180ms ease;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    color: var(--color-ink);
    background: var(--color-background);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button, input, select { font: inherit; }
button { touch-action: manipulation; }
button:not(:disabled), summary, tbody tr { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
svg { display: block; }

.hidden { display: none !important; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    z-index: 1000;
    top: 12px;
    left: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: #fff;
    background: var(--color-primary);
    transform: translateY(-160%);
    transition: transform var(--ease);
}
.skip-link:focus { transform: translateY(0); }

.eyebrow {
    margin: 0 0 10px;
    color: var(--color-primary);
    font-size: 12px;
    font-weight: 750;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.brand-mark {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    color: #fff;
    background: linear-gradient(145deg, #3d73f3, #214cbf);
    box-shadow: inset 0 1px rgba(255, 255, 255, .25), 0 7px 16px rgba(36, 87, 214, .2);
    font-family: Georgia, serif;
    font-size: 25px;
    font-weight: 800;
}

.primary, .ghost {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 17px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    transition: color var(--ease), background var(--ease), border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}
.primary svg, .ghost svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.primary { color: #fff; background: var(--color-primary); box-shadow: 0 5px 14px rgba(36, 87, 214, .18); }
.primary:hover { background: var(--color-primary-hover); box-shadow: 0 7px 18px rgba(36, 87, 214, .22); transform: translateY(-1px); }
.primary:active { transform: translateY(0); }
.ghost { color: #344054; background: var(--color-surface); border-color: var(--color-border-strong); box-shadow: 0 1px 2px rgba(16, 24, 40, .03); }
.ghost:hover { color: var(--color-ink); background: #f9fafb; border-color: #b8c0cc; }
.primary:disabled, .ghost:disabled { cursor: not-allowed; opacity: .48; box-shadow: none; transform: none; }

button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, tbody tr:focus-visible, .skip-link:focus-visible {
    outline: 3px solid rgba(36, 87, 214, .22);
    outline-offset: 2px;
}

label > span {
    display: block;
    margin-bottom: 8px;
    color: #344054;
    font-size: 13px;
    font-weight: 650;
}
input, select {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--color-border-strong);
    border-radius: 10px;
    padding: 10px 13px;
    color: var(--color-ink);
    background: var(--color-surface);
    transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}
input:hover, select:hover { border-color: #aeb8c5; }
input:focus, select:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(36, 87, 214, .12); outline: 0; }
input::placeholder { color: var(--color-subtle); }

.readonly {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: max-content;
    border: 1px solid #abefc6;
    border-radius: 999px;
    padding: 6px 10px;
    color: #067647;
    background: var(--color-success-soft);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}
.readonly i, .status i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #17b26a;
    box-shadow: 0 0 0 3px rgba(23, 178, 106, .13);
}

.message {
    margin: 0 0 20px;
    border: 1px solid #abefc6;
    border-radius: 10px;
    padding: 12px 15px;
    color: #067647;
    background: var(--color-success-soft);
    font-size: 14px;
}
.message.error { color: var(--color-danger); background: var(--color-danger-soft); border-color: #fecdca; }

/* Login */
.login-view {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 48px 24px;
    background:
        radial-gradient(circle at 50% -20%, rgba(59, 130, 246, .12), transparent 38%),
        var(--color-background);
}
.login-panel { width: min(480px, 100%); }
.login-brand {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 13px;
    margin-bottom: 25px;
    color: var(--color-ink);
}
.login-brand strong, .login-brand small { display: block; }
.login-brand strong { font-size: 14px; letter-spacing: .13em; }
.login-brand small { margin-top: 2px; color: var(--color-muted); font-size: 11px; letter-spacing: .08em; }
.login-form {
    display: grid;
    gap: 22px;
    padding: 38px;
    border: 1px solid rgba(208, 213, 221, .85);
    border-radius: 20px;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 24px 55px rgba(16, 24, 40, .09);
    animation: enter 260ms ease-out both;
}
.login-form header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 2px; }
.login-form h1 { margin: 0 0 8px; font-size: 32px; line-height: 1.18; letter-spacing: -.035em; }
.login-form header p:last-child { margin: 0; color: var(--color-muted); font-size: 14px; }
.login-form > .primary { min-height: 52px; justify-content: space-between; padding-inline: 18px; font-size: 16px; }
.login-form > small { color: var(--color-muted); font-size: 12px; line-height: 1.65; text-align: center; }
.login-form .message { margin: -6px 0 0; }

/* App shell */
.app { min-height: 100vh; }
.workspace { min-width: 0; padding: 0 max(24px, calc((100vw - var(--content-width)) / 2)) 56px; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 76px;
    margin: 0 min(-24px, calc((var(--content-width) - 100vw) / 2)) 44px;
    padding: 14px max(24px, calc((100vw - var(--content-width)) / 2));
    color: #fff;
    background: var(--color-nav);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .06);
}
.topbar-brand, .topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-brand strong, .topbar-brand small, .topbar-user strong, .topbar-user small { display: block; }
.topbar-brand strong { font-size: 14px; letter-spacing: .12em; }
.topbar-brand small { margin-top: 3px; color: #98a2b3; font-size: 11px; }
.topbar .brand-mark { width: 39px; height: 39px; border-radius: 10px; font-size: 23px; }
.topbar-user .avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 50%;
    color: #dbe7ff;
    background: #26354f;
    font-size: 13px;
    font-weight: 750;
}
.topbar-user strong { font-size: 13px; }
.topbar-user small { margin-top: 2px; color: #98a2b3; font-size: 11px; }
.topbar-user .ghost { min-height: 40px; margin-left: 6px; color: #eaecf0; background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .16); box-shadow: none; }
.topbar-user .ghost:hover { color: #fff; background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .26); }

.workspace-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 28px; margin-bottom: 30px; }
.workspace-head h1 { margin: 0 0 8px; font-size: clamp(34px, 3.2vw, 44px); line-height: 1.12; letter-spacing: -.04em; }
.workspace-head p:last-child { max-width: 620px; margin: 0; color: var(--color-muted); font-size: 15px; }
.workspace-actions { display: flex; flex: 0 0 auto; gap: 9px; }

.summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.summary > div {
    min-width: 0;
    padding: 20px 22px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .025);
}
.summary span, .summary strong { display: block; }
.summary span { color: var(--color-muted); font-size: 13px; font-weight: 550; }
.summary strong { margin-top: 6px; font-size: 29px; line-height: 1.15; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.summary .source-value { overflow: hidden; color: var(--color-primary); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 17px; line-height: 1.6; text-overflow: ellipsis; white-space: nowrap; }

/* Filters */
.filters {
    display: grid;
    grid-template-columns: minmax(280px, 1.45fr) repeat(3, minmax(140px, .7fr)) auto;
    align-items: end;
    gap: 15px;
    margin-bottom: 20px;
    padding: 20px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
}
.search > div { position: relative; }
.search svg { position: absolute; top: 14px; left: 14px; width: 20px; height: 20px; fill: none; stroke: var(--color-muted); stroke-width: 1.8; stroke-linecap: round; }
.search input { padding-left: 43px; }
.filters details { grid-column: 1 / -2; min-width: 0; }
.filters summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 4px 2px;
    color: var(--color-primary);
    font-size: 13px;
    font-weight: 700;
    list-style: none;
}
.filters summary::-webkit-details-marker { display: none; }
.filters summary svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--ease); }
.filters details[open] summary svg { transform: rotate(180deg); }
.more-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; padding-top: 13px; }
.filter-actions { display: flex; gap: 8px; }

/* Data table */
.table-shell {
    position: relative;
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}
table { width: 100%; min-width: 1050px; border-collapse: collapse; }
th, td { padding: 17px 18px; border-bottom: 1px solid #edf0f3; text-align: left; vertical-align: middle; }
th {
    color: var(--color-muted);
    background: #f9fafb;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .055em;
    text-transform: uppercase;
    white-space: nowrap;
}
td { color: #344054; font-size: 14px; font-variant-numeric: tabular-nums; }
td > strong, td > small { display: block; }
td > strong { color: var(--color-ink); font-weight: 650; }
td > small, .person small { margin-top: 4px; color: var(--color-muted); font-size: 11px; }
tbody tr { transition: background var(--ease); }
tbody tr:hover { background: #f8faff; }
tbody tr:focus-visible { position: relative; z-index: 1; outline-offset: -3px; }
tbody tr:last-child td { border-bottom: 0; }
.person { display: flex; align-items: center; gap: 12px; }
.person .avatar, .large-avatar {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 50%;
    color: #2647a8;
    background: #e9efff;
    font-weight: 750;
}
.person .avatar { width: 40px; height: 40px; font-size: 13px; }
.person strong, .person small { display: block; }
.role { display: inline-flex; border: 1px solid #d6e1ff; border-radius: 999px; padding: 4px 9px; color: #2949a7; background: #f2f5ff; font-size: 12px; font-weight: 700; }
.status { display: inline-flex; align-items: center; gap: 8px; color: var(--color-success); font-size: 13px; font-weight: 650; white-space: nowrap; }
.status.disabled { color: var(--color-danger); }
.status.disabled i { background: #f04438; box-shadow: 0 0 0 3px rgba(240, 68, 56, .12); }
.view {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--color-primary);
    background: var(--color-primary-soft);
    transition: color var(--ease), background var(--ease), border-color var(--ease);
}
.view svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.view:hover { color: #fff; background: var(--color-primary); }
.empty { height: 190px; color: var(--color-muted); text-align: center; cursor: default; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--color-primary); background: rgba(255, 255, 255, .9); font-size: 14px; font-weight: 650; backdrop-filter: blur(2px); }
.loading::before { content: ""; width: 24px; height: 24px; margin-bottom: 44px; position: absolute; border: 3px solid #dbe5ff; border-top-color: var(--color-primary); border-radius: 50%; animation: spin .8s linear infinite; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 17px; color: var(--color-muted); font-size: 13px; }
.pager div { display: flex; gap: 8px; }
.pager button { min-height: 42px; padding: 8px 13px; font-size: 13px; }
.pager button svg { width: 16px; height: 16px; }

/* Detail drawer */
dialog {
    width: min(720px, 100vw);
    max-width: none;
    height: 100vh;
    max-height: none;
    margin: 0 0 0 auto;
    border: 0;
    padding: 0;
    color: var(--color-ink);
    background: var(--color-surface);
    box-shadow: var(--shadow-dialog);
}
dialog[open] { animation: drawer-in 240ms ease-out both; }
dialog::backdrop { background: rgba(16, 24, 40, .52); backdrop-filter: blur(2px); }
.drawer { min-height: 100%; display: flex; flex-direction: column; margin: 0; }
.drawer > header { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 28px 34px; border-bottom: 1px solid var(--color-border); }
.identity { display: flex; align-items: center; gap: 14px; min-width: 0; }
.large-avatar { width: 52px; height: 52px; color: #fff; background: var(--color-primary); font-size: 16px; }
.identity h2 { overflow: hidden; margin: 0 0 3px; font-size: 26px; line-height: 1.25; letter-spacing: -.025em; text-overflow: ellipsis; white-space: nowrap; }
.identity small { color: var(--color-muted); font-size: 12px; }
.close { display: grid; flex: 0 0 auto; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 10px; color: #475467; background: #f2f4f7; font-size: 25px; line-height: 1; transition: background var(--ease), color var(--ease); }
.close:hover { color: var(--color-ink); background: #e4e7ec; }
.detail-content { flex: 1; overflow-y: auto; padding: 5px 34px 30px; }
.detail-content section { padding: 25px 0; border-bottom: 1px solid var(--color-border); }
.detail-content section:last-child { border-bottom: 0; }
.detail-content h3 { margin: 0 0 18px; color: var(--color-primary); font-size: 13px; font-weight: 750; letter-spacing: .035em; }
.detail-content dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 28px; margin: 0; }
.detail-content dt { margin-bottom: 5px; color: var(--color-muted); font-size: 11px; font-weight: 650; }
.detail-content dd { margin: 0; color: #344054; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.yes { color: var(--color-success); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; border: 1px solid #d6e1ff; border-radius: 999px; padding: 4px 8px; color: #2949a7; background: #f2f5ff; font-size: 11px; font-weight: 650; }
.drawer > footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 34px; border-top: 1px solid var(--color-border); background: #f9fafb; }

@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
@keyframes drawer-in { from { opacity: .7; transform: translateX(32px); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1200px) {
    .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters details { grid-column: 1 / -1; }
    .filter-actions { grid-column: 2; justify-content: flex-end; }
    .more-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .workspace { padding-inline: 16px; padding-bottom: 36px; }
    .topbar { min-height: 68px; margin: 0 -16px 30px; padding: 12px 16px; }
    .topbar-brand small, .topbar-user > span:nth-child(2) { display: none; }
    .topbar-user { gap: 7px; }
    .topbar-user .avatar { width: 36px; height: 36px; }
    .topbar-user .ghost { min-height: 40px; margin-left: 0; padding-inline: 11px; font-size: 12px; }
    .workspace-head { align-items: flex-start; margin-bottom: 24px; }
    .workspace-head h1 { font-size: 34px; }
    .workspace-head p:last-child { max-width: 230px; font-size: 13px; }
    .workspace-actions button { min-height: 44px; padding: 9px 12px; white-space: nowrap; }
    .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .summary > div { padding: 16px; }
    .summary strong { font-size: 25px; }
    .summary .source-value { font-size: 14px; }
    .filters { grid-template-columns: 1fr; padding: 17px; }
    .filters details, .filter-actions { grid-column: 1; }
    .filter-actions button { flex: 1; }
    .more-fields { grid-template-columns: 1fr; }
    .pager { align-items: flex-start; }
    .pager > span { max-width: 155px; line-height: 1.55; }
    dialog { width: 100vw; }
    .drawer > header, .detail-content, .drawer > footer { padding-inline: 21px; }
    .detail-content dl { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .login-view { padding: 28px 16px; }
    .login-brand { margin-bottom: 19px; }
    .login-form { gap: 20px; padding: 27px 21px; border-radius: 17px; }
    .login-form h1 { font-size: 29px; }
    .login-form header { gap: 12px; }
    .workspace-head { display: grid; grid-template-columns: 1fr; }
    .workspace-head p:last-child { max-width: none; }
    .workspace-actions { width: 100%; }
    .workspace-actions button { flex: 1; }
    .pager { display: grid; }
    .pager > span { max-width: none; }
    .pager div, .pager button { flex: 1; }
    .drawer > footer .readonly { display: none; }
    .drawer > footer .ghost { width: 100%; }
}

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