@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=Noto+Sans+TC:wght@400;500;700&display=swap');

:root {
    --ink: #18242c;
    --ink-soft: #52616a;
    --paper: #f5f8f7;
    --panel: #ffffff;
    --line: #dce6e3;
    --teal: #187c76;
    --teal-deep: #0f5b5a;
    --teal-wash: #e1f2ee;
    --amber: #d78c2e;
    --amber-wash: #fff3d9;
    --coral: #c85c52;
    --coral-wash: #fff0ed;
    --shadow: 0 16px 40px rgba(24, 48, 53, 0.08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: 'IBM Plex Sans', 'Noto Sans TC', sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 90% 0%, rgba(197, 232, 223, 0.64), transparent 34rem),
        radial-gradient(circle at 0% 100%, rgba(255, 231, 194, 0.45), transparent 30rem),
        var(--paper);
}

body { min-width: 320px; }

#blazor-error-ui {
    display: none;
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    padding: 0.75rem 1rem;
    color: #5b1f1a;
    background: #fff0ed;
    box-shadow: 0 -2px 8px rgba(24, 36, 44, 0.16);
    text-align: center;
}

#blazor-error-ui .reload {
    margin-left: 0.5rem;
    color: var(--coral);
    font-weight: 700;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.52; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0.5rem; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.05; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 1.6rem; letter-spacing: 0; }

.admin-loading {
    display: grid;
    min-height: 100vh;
    place-items: center;
    color: var(--ink-soft);
}

.admin-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.admin-sidebar {
    display: flex;
    position: sticky;
    top: 0;
    flex-direction: column;
    height: 100vh;
    padding: 1.5rem 1.1rem 1.2rem;
    color: #eaf6f3;
    background: linear-gradient(165deg, #17383d 0%, #10272d 70%, #0d2025 100%);
}
.brand-lockup, .login-heading { display: flex; align-items: center; gap: 0.75rem; }
.brand-lockup strong { display: block; font-size: 1.04rem; letter-spacing: 0.02em; }
.brand-lockup small { display: block; margin-top: 0.18rem; color: #a9c5c2; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }
.brand-mark { display: grid; width: 2.4rem; height: 2.4rem; place-items: center; color: #17383d; background: #f3bd57; font-weight: 700; border-radius: 8px; }
.admin-nav { display: grid; gap: 0.4rem; margin-top: 3.4rem; }
.admin-nav a { padding: 0.75rem 0.85rem; border-left: 3px solid transparent; color: #b9d2cf; font-size: 0.94rem; font-weight: 600; transition: background 120ms ease, color 120ms ease, border-color 120ms ease; }
.admin-nav a:hover, .admin-nav a.active { border-left-color: #f3bd57; color: #ffffff; background: rgba(255, 255, 255, 0.09); }
.sidebar-footer { display: grid; gap: 0.45rem; margin-top: auto; padding-top: 1rem; border-top: 1px solid rgba(222, 245, 239, 0.16); }
.admin-role { color: #f3bd57; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em; }
.admin-email { overflow: hidden; color: #c1d8d4; font-size: 0.78rem; text-overflow: ellipsis; white-space: nowrap; }
.link-button { padding: 0; border: 0; color: var(--teal); background: transparent; font-weight: 600; text-align: left; }
.admin-sidebar .link-button { margin-top: 0.35rem; color: #f3bd57; }
.danger-link { color: var(--coral); }

.admin-main { min-width: 0; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.15rem clamp(1.2rem, 4vw, 4.5rem); border-bottom: 1px solid rgba(24, 36, 44, 0.08); background: rgba(245, 248, 247, 0.76); backdrop-filter: blur(16px); }
.admin-content { width: min(1180px, 100%); margin: 0 auto; padding: clamp(1.4rem, 4vw, 3.6rem) clamp(1.2rem, 4vw, 4.5rem) 4rem; }
.eyebrow { display: block; color: var(--teal); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.16em; line-height: 1.4; text-transform: uppercase; }
.session-chip { padding: 0.35rem 0.65rem; border: 1px solid #b9ddd5; color: var(--teal-deep); background: var(--teal-wash); font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; }
.compact-heading { align-items: flex-start; }
.page-lede { max-width: 650px; margin-bottom: 0; color: var(--ink-soft); font-size: 1rem; line-height: 1.6; }
.heading-stat { display: grid; min-width: 132px; padding: 0.8rem 1rem; border-left: 3px solid var(--amber); background: rgba(255, 255, 255, 0.62); }
.heading-stat strong { font-size: 1.65rem; line-height: 1; }
.heading-stat span { margin-top: 0.35rem; color: var(--ink-soft); font-size: 0.75rem; }
.back-link { display: inline-block; margin-bottom: 1.2rem; color: var(--teal); font-size: 0.82rem; font-weight: 700; }
.id-text { display: block; color: #829097; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.72rem; overflow-wrap: anywhere; }

.panel { border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
.panel-caption { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.15rem; border-bottom: 1px solid var(--line); font-size: 0.83rem; font-weight: 700; letter-spacing: 0.02em; }
.muted-note { color: var(--ink-soft); font-size: 0.78rem; }
.empty-state, .empty-inline { color: var(--ink-soft); text-align: center; }
.empty-state { padding: 3rem 1rem; }
.empty-inline { padding: 1.8rem 1rem; }
.alert { margin-bottom: 1.2rem; padding: 0.8rem 1rem; border-left: 3px solid; font-size: 0.88rem; }
.alert-error { border-color: var(--coral); color: #873b34; background: var(--coral-wash); }
.status-callout { display: grid; gap: 0.35rem; margin-bottom: 1rem; padding: 0.9rem 1rem; border-left: 3px solid; font-size: 0.86rem; }
.warning-callout { border-color: var(--amber); color: #765016; background: var(--amber-wash); }
.action-divider { height: 1px; margin: 1.5rem 0; background: var(--line); }

.filter-bar { display: grid; grid-template-columns: minmax(220px, 1fr) 180px auto; align-items: end; gap: 0.8rem; margin-bottom: 1.5rem; }
.filter-search, .filter-select, .field-group { display: grid; gap: 0.4rem; }
.field-group label, .field-label, .filter-bar label { color: var(--ink-soft); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; }
.field-input, .table-input { width: 100%; min-height: 2.55rem; padding: 0.6rem 0.7rem; border: 1px solid #c9d8d5; color: var(--ink); background: #fbfdfc; outline: none; }
.field-input:focus, .table-input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(24, 124, 118, 0.12); }
textarea.field-input { resize: vertical; }
.primary-button, .secondary-button, .danger-button { min-height: 2.55rem; padding: 0.6rem 0.95rem; border: 1px solid transparent; font-weight: 700; transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease; }
.primary-button:hover:not(:disabled), .secondary-button:hover:not(:disabled), .danger-button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 5px 13px rgba(23, 66, 70, 0.12); }
.primary-button { color: #ffffff; background: var(--teal); }
.primary-button:hover:not(:disabled) { background: var(--teal-deep); }
.secondary-button { border-color: #bdd0cc; color: var(--teal-deep); background: #ffffff; }
.danger-button { color: #8a3931; background: var(--coral-wash); border-color: #e9b6ae; }
.inline-button { display: inline-block; margin-top: 0.8rem; }
.wide-button { width: 100%; }

.table-panel { overflow: hidden; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 0.86rem; }
.data-table th { padding: 0.7rem 1.15rem; color: #718087; background: #f7faf9; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 0.95rem 1.15rem; border-top: 1px solid #edf2f0; vertical-align: middle; }
.data-table tbody tr:hover { background: #fbfdfc; }
.compact-table { min-width: 620px; }
.member-link, .table-action { color: var(--teal); font-weight: 700; }
.member-link:hover, .table-action:hover, .back-link:hover { text-decoration: underline; }
.cell-primary, .cell-secondary { display: block; }
.cell-primary { font-weight: 600; }
.cell-secondary { margin-top: 0.2rem; color: var(--ink-soft); font-size: 0.76rem; }
.grant-mark, .source-mark, .code-mark { color: var(--teal-deep); font-weight: 700; }
.code-mark { letter-spacing: 0.08em; }
.status-badge { display: inline-flex; padding: 0.25rem 0.55rem; border: 1px solid; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; text-transform: capitalize; white-space: nowrap; }
.status-active, .status-enabled, .status-completed { border-color: #a9d7cb; color: #126b61; background: var(--teal-wash); }
.status-suspended, .status-disabled, .status-canceled, .status-revoked { border-color: #e7b2aa; color: #8a3931; background: var(--coral-wash); }
.status-created, .status-pending { border-color: #eed39a; color: #795719; background: var(--amber-wash); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; padding: 1rem; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 0.8rem; }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; margin-bottom: 1.2rem; }
.detail-stack { display: grid; gap: 1.2rem; }
.detail-panel { min-height: 100%; padding-bottom: 1.2rem; }
.detail-panel > .field-group, .detail-panel > .primary-button, .detail-panel > .danger-button, .detail-panel > .secondary-button, .status-callout, .subsection-list { margin-right: 1.15rem; margin-left: 1.15rem; }
.detail-panel > .field-group { margin-top: 1rem; }
.detail-panel > .primary-button, .detail-panel > .danger-button, .detail-panel > .secondary-button { margin-top: 1rem; }
.subsection-list { margin-top: 1.2rem; border-top: 1px solid var(--line); }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.85rem 0; border-bottom: 1px solid #edf2f0; }
.row-end { display: grid; justify-items: end; gap: 0.35rem; }

.create-panel { margin-bottom: 1.5rem; }
.discount-form { display: grid; grid-template-columns: 1.1fr 0.75fr 0.55fr 1.5fr auto; align-items: end; gap: 0.8rem; padding: 1.15rem; }
.editing-row { background: #fffaf0; }
.table-input { min-width: 100px; min-height: 2.2rem; padding: 0.4rem 0.5rem; }
.wide-input { min-width: 190px; }
.action-cell { white-space: nowrap; }
.action-cell .link-button { margin-right: 0.8rem; }

.login-shell { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr); min-height: 100vh; }
.login-visual { position: relative; display: flex; min-height: 100vh; flex-direction: column; justify-content: space-between; overflow: hidden; padding: clamp(2rem, 7vw, 7rem); color: #ecf8f4; background: linear-gradient(145deg, #163b40, #0d252c); }
.visual-grid { position: absolute; inset: 0; opacity: 0.42; background-image: linear-gradient(rgba(168, 223, 210, 0.13) 1px, transparent 1px), linear-gradient(90deg, rgba(168, 223, 210, 0.13) 1px, transparent 1px); background-size: 44px 44px; mask-image: linear-gradient(to bottom right, black, transparent 78%); }
.visual-copy, .visual-stamp { position: relative; z-index: 1; }
.visual-copy { max-width: 520px; margin-top: auto; margin-bottom: auto; }
.visual-copy .eyebrow { color: #f3bd57; }
.visual-copy h1 { max-width: 470px; margin-top: 1rem; color: #ffffff; font-size: clamp(3rem, 7vw, 6.6rem); letter-spacing: -0.04em; }
.visual-copy p { max-width: 360px; color: #b8d2cd; font-size: 1.05rem; line-height: 1.65; }
.visual-stamp { align-self: flex-end; color: #f3bd57; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.18em; }
.login-panel { display: grid; align-content: center; width: min(430px, 100%); margin: 0 auto; padding: 2.2rem; }
.login-heading { margin-bottom: 2rem; }
.stack-form { display: grid; gap: 1.2rem; }
.login-panel .muted-note { margin-top: 1.3rem; line-height: 1.5; }
.validation-message { color: var(--coral); font-size: 0.75rem; }

.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; }

@media (max-width: 980px) {
    .admin-shell { grid-template-columns: 190px minmax(0, 1fr); }
    .discount-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .discount-form .plan-field { grid-column: span 2; }
}

@media (max-width: 720px) {
    .admin-shell { display: block; }
    .admin-sidebar { position: static; height: auto; padding: 1rem; }
    .admin-nav { display: flex; overflow-x: auto; margin-top: 1.2rem; }
    .admin-nav a { border-bottom: 3px solid transparent; border-left: 0; white-space: nowrap; }
    .admin-nav a:hover, .admin-nav a.active { border-bottom-color: #f3bd57; border-left: 0; }
    .sidebar-footer { grid-template-columns: 1fr auto; margin-top: 1rem; padding-top: 0.8rem; }
    .sidebar-footer .admin-role, .sidebar-footer .admin-email { grid-column: 1; }
    .sidebar-footer .link-button { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
    .admin-topbar { padding: 0.85rem 1rem; }
    .admin-content { padding: 1.5rem 1rem 2.5rem; }
    .page-heading { align-items: flex-start; flex-direction: column; gap: 1rem; }
    .heading-stat { min-width: 120px; }
    .filter-bar, .detail-grid { grid-template-columns: 1fr; }
    .filter-button { width: 100%; }
    .discount-form { grid-template-columns: 1fr; }
    .discount-form .plan-field { grid-column: auto; }
    .login-shell { display: block; }
    .login-visual { min-height: 260px; padding: 1.5rem; }
    .visual-copy { margin-top: 3rem; }
    .visual-copy h1 { margin-top: 0.5rem; font-size: 3.2rem; }
    .login-panel { width: 100%; padding: 2.2rem 1.5rem; }
}
