:root {
    --ink: #172033;
    --muted: #6f788b;
    --line: #e5e8ef;
    --canvas: #f5f7fb;
    --panel: #ffffff;
    --blue: #5367e8;
    --blue-dark: #3f51cf;
    --blue-soft: #eef0ff;
    --green: #25a56a;
    --green-soft: #e9f8f0;
    --red: #d94b60;
    --red-soft: #fff0f2;
    --amber: #c98b21;
    --amber-soft: #fff7e5;
    --shadow: 0 12px 36px rgba(34, 43, 72, .08);
    --radius: 20px;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--canvas);
    font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(30px, 4vw, 44px); line-height: 1.08; letter-spacing: -.04em; }
h2 { margin-bottom: 8px; font-size: 21px; letter-spacing: -.025em; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: 8px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .16em; }

.topbar {
    position: sticky; top: 0; z-index: 20; height: 76px; padding: 0 max(24px, calc((100vw - 1320px) / 2));
    display: grid; grid-template-columns: 240px 1fr auto; align-items: center; gap: 28px;
    background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 11px; }
.brand-mark, .login-logo { display: grid; place-items: center; color: white; background: linear-gradient(145deg, #6477ef, #3649c6); box-shadow: 0 8px 18px rgba(65,82,210,.25); font-weight: 900; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; }
.brand span:last-child { display: flex; flex-direction: column; font-size: 15px; line-height: 1.05; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; }
.nav { justify-self: center; display: flex; align-self: stretch; gap: 6px; }
.nav a { position: relative; display: grid; place-items: center; padding: 0 15px; color: var(--muted); font-size: 14px; font-weight: 650; }
.nav a:hover, .nav a.active { color: var(--ink); }
.nav a.active::after { content: ""; position: absolute; right: 14px; bottom: -1px; left: 14px; height: 3px; border-radius: 3px 3px 0 0; background: var(--blue); }
.account { display: flex; align-items: center; gap: 10px; }
.account img, .avatar { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 12px; object-fit: cover; }
.avatar { display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); font-weight: 800; }
.account-copy { display: flex; min-width: 115px; flex-direction: column; font-size: 12px; }
.account-copy small { margin-top: 2px; color: var(--muted); text-transform: capitalize; }
.icon-button { width: 34px; height: 34px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; }
.icon-button:hover { color: var(--ink); background: var(--canvas); }

.shell { width: min(1320px, calc(100% - 48px)); margin: 0 auto; padding: 34px 0 70px; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 36px; background: radial-gradient(circle at 15% 15%, #e8ebff 0, transparent 32%), radial-gradient(circle at 90% 90%, #e8f4ff 0, transparent 28%), var(--canvas); }
.flash { margin-bottom: 18px; padding: 14px 18px; display: flex; align-items: center; gap: 10px; border: 1px solid; border-radius: 14px; font-size: 14px; font-weight: 600; }
.flash > span { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.flash-success { color: #14764a; border-color: #bce9d1; background: var(--green-soft); }
.flash-success > span { color: white; background: var(--green); }
.flash-warning { color: #8b5d0c; border-color: #f0d494; background: var(--amber-soft); }
.flash-warning > span { color: white; background: var(--amber); }

.hero-upload { margin-bottom: 22px; padding: 31px; overflow: hidden; border: 1px solid #dfe3ed; border-radius: 26px; background: var(--panel); box-shadow: var(--shadow); }
.hero-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.hero-heading h1 { font-size: clamp(30px, 4vw, 46px); }
.hero-heading p:not(.eyebrow) { max-width: 690px; margin-bottom: 26px; color: var(--muted); font-size: 16px; }
.hero-badge { padding: 8px 13px; border: 1px solid #dfe3ff; border-radius: 999px; color: var(--blue); background: var(--blue-soft); font-size: 12px; font-weight: 700; white-space: nowrap; }
.drop-zone { min-height: 245px; padding: 36px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 2px dashed #c9cfde; border-radius: 20px; background: linear-gradient(135deg, #fafbff, #f7f8fc); text-align: center; transition: .2s ease; cursor: pointer; }
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--blue); background: var(--blue-soft); transform: translateY(-1px); }
.drop-zone.has-files { min-height: 170px; border-color: var(--green); background: var(--green-soft); }
.drop-zone input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.drop-zone strong { margin: 12px 0 6px; font-size: 20px; }
.drop-zone > span:not(.upload-icon) { color: var(--muted); font-size: 14px; }
.drop-zone em { margin-top: 15px; color: #939bad; font-size: 11px; font-style: normal; font-weight: 700; letter-spacing: .08em; }
.upload-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 17px; color: var(--blue); background: white; box-shadow: 0 8px 24px rgba(62,76,160,.12); }
.upload-icon svg { width: 30px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.selected-files { margin-top: 12px; padding: 10px 14px; border-radius: 12px; color: #19764d; background: var(--green-soft); font-size: 13px; }
.selected-files span { margin-right: 8px; }
.upload-controls { margin-top: 18px; display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.field input, .field select, .filters input, .filters select, .upload-controls select { height: 46px; padding: 0 14px; border: 1px solid #d9dde7; border-radius: 12px; outline: none; color: var(--ink); background: white; }
.field input:focus, .field select:focus, .filters input:focus, .filters select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(83,103,232,.12); }
.calendar-select { width: min(470px, 100%); }

.button { min-height: 43px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid transparent; border-radius: 12px; font-weight: 750; font-size: 13px; transition: .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled, .button.disabled { cursor: not-allowed; opacity: .45; transform: none; pointer-events: none; }
.button-primary { color: white; background: var(--blue); box-shadow: 0 8px 18px rgba(83,103,232,.2); }
.button-primary:hover { background: var(--blue-dark); }
.button-secondary { border-color: var(--line); background: white; }
.button-danger { color: white; background: var(--red); }
.button-danger-outline { width: 100%; color: var(--red); border-color: #f0b9c1; background: var(--red-soft); }
.button-large { min-width: 220px; height: 49px; }
.button-large b { font-size: 18px; }
.button-small { min-height: 34px; padding: 0 11px; font-size: 11px; }

.stats-grid { margin: 22px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card { padding: 20px; display: flex; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.stat-card > div { display: flex; flex-direction: column; }
.stat-card strong { font-size: 27px; line-height: 1; }
.stat-card div span { margin-top: 6px; color: var(--muted); font-size: 12px; }
.stat-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; font-weight: 800; }
.stat-icon.blue { color: var(--blue); background: var(--blue-soft); }
.stat-icon.green { color: var(--green); background: var(--green-soft); }
.stat-icon.red { color: var(--red); background: var(--red-soft); }
.stat-icon.amber { color: var(--amber); background: var(--amber-soft); }
.dashboard-grid { display: grid; grid-template-columns: 1.65fr .75fr; gap: 20px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 7px 24px rgba(35,43,70,.045); }
.dashboard-grid > .panel, .import-report { padding: 24px; }
.section-heading, .page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.section-heading { margin-bottom: 14px; }
.section-heading h2 { margin-bottom: 0; }
.section-heading a { color: var(--blue); font-size: 12px; font-weight: 700; }
.batch-row, .user-row { min-height: 64px; display: flex; align-items: center; gap: 13px; border-top: 1px solid #eef0f4; }
.batch-row:first-child, .user-row:first-child { border-top: 0; }
.batch-icon { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 11px; color: var(--blue); background: var(--blue-soft); font-size: 9px; font-weight: 900; }
.batch-row > div:nth-child(2), .user-row > div { display: flex; flex: 1; min-width: 0; flex-direction: column; }
.batch-row small, .user-row small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.batch-result { display: flex; gap: 9px; color: var(--green); font-size: 12px; font-weight: 750; }
.text-danger { color: var(--red) !important; }
.cleanup-panel > p:not(.eyebrow) { color: var(--muted); font-size: 13px; line-height: 1.55; }
.cleanup-count { margin: 24px 0; display: flex; align-items: center; gap: 13px; }
.cleanup-count strong { font-size: 42px; letter-spacing: -.05em; }
.cleanup-count span { color: var(--muted); font-size: 12px; line-height: 1.35; }
.check { margin: 12px 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.check input { accent-color: var(--blue); }
.empty-copy { padding: 20px 0 5px; }

.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.result-grid div { padding: 14px; display: flex; flex-direction: column; border-radius: 14px; background: var(--canvas); }
.result-grid strong { font-size: 24px; }
.result-grid span { color: var(--muted); font-size: 11px; }
.result-grid .has-error { color: var(--red); background: var(--red-soft); }
.import-report { margin-bottom: 22px; }
.import-report details { margin-top: 15px; color: var(--muted); font-size: 12px; }
.import-report summary { cursor: pointer; }
.report-list { margin-top: 10px; display: grid; gap: 6px; }
.report-list div { display: flex; gap: 8px; }
.status-dot { width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: var(--green); }
.status-dot.status-error { background: var(--red); }

.page-heading { margin-bottom: 24px; align-items: center; }
.page-heading h1 { margin-bottom: 5px; }
.page-heading p:not(.eyebrow) { margin-bottom: 0; color: var(--muted); }
.filters { padding: 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1; }
.search span { position: absolute; top: 11px; left: 14px; color: var(--muted); }
.search input { width: 100%; padding-left: 38px; }
.filters select { min-width: 180px; }
.check.compact { margin: 0 6px; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 13px 17px; color: #9299a9; background: #fafbfc; font-size: 10px; text-align: left; text-transform: uppercase; letter-spacing: .08em; }
td { padding: 15px 17px; border-top: 1px solid #edf0f4; vertical-align: middle; }
td small { max-width: 260px; margin-top: 4px; display: block; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.record-link { color: var(--blue); font-weight: 800; }
.route { max-width: 260px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.row-arrow { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: var(--canvas); font-size: 21px; }
.empty-cell { padding: 50px; color: var(--muted); text-align: center; }
.status, .tag { padding: 6px 9px; display: inline-flex; border-radius: 999px; color: var(--muted); background: #eef0f4; font-size: 10px; font-weight: 800; text-transform: uppercase; white-space: nowrap; }
.status-synced, .tag-green { color: #14764a; background: var(--green-soft); }
.status-error { color: var(--red); background: var(--red-soft); }
.status-cancelled { color: #777; background: #eceef2; }
.status-missing_google { color: #8b5d0c; background: var(--amber-soft); }
.status-pending { color: var(--amber); background: var(--amber-soft); }
.breadcrumbs { margin-bottom: 18px; display: flex; gap: 9px; color: var(--muted); font-size: 12px; }
.breadcrumbs a { color: var(--blue); }
.detail-grid { display: grid; grid-template-columns: 1.5fr .8fr; gap: 20px; }
.detail-card { padding: 25px; }
dl { margin: 0; }
dl > div { padding: 13px 0; display: grid; grid-template-columns: 145px 1fr; gap: 15px; border-top: 1px solid #edf0f4; }
dl > div:first-child { border-top: 0; }
dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
dd { margin: 0; font-size: 13px; line-height: 1.5; }
.preline { white-space: pre-line; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
hr { margin: 20px 0; border: 0; border-top: 1px solid var(--line); }

.cards-list { display: grid; gap: 13px; }
.calendar-card { padding: 20px; display: grid; grid-template-columns: 6px 1fr auto; align-items: center; gap: 18px; }
.calendar-color { width: 6px; height: 52px; border-radius: 6px; background: var(--blue); }
.calendar-card h2 { margin-bottom: 4px; }
.calendar-card p { max-width: 650px; margin-bottom: 5px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.calendar-card small { color: var(--muted); font-size: 11px; }
.calendar-actions { display: flex; align-items: center; gap: 8px; }
.calendar-sync-state { grid-column: 2 / -1; color: var(--muted); font-size: 11px; }
.users-grid { grid-template-columns: 1.4fr .7fr; }
.user-row .status { margin-left: auto; }
.add-user p:not(.eyebrow) { color: var(--muted); font-size: 13px; line-height: 1.5; }
.add-user form { display: grid; gap: 15px; }

.empty-state { padding: 55px 20px; text-align: center; }
.empty-state p { color: var(--muted); }
.empty-icon { width: 52px; height: 52px; margin: 0 auto 13px; display: grid; place-items: center; border-radius: 16px; color: var(--blue); background: var(--blue-soft); font-size: 28px; }
.error-card { width: min(560px, 100%); margin: 8vh auto; padding: 48px; border: 1px solid var(--line); border-radius: 24px; background: white; text-align: center; box-shadow: var(--shadow); }
.error-card > span { width: 58px; height: 58px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 18px; color: var(--red); background: var(--red-soft); font-size: 26px; font-weight: 800; }

.login-card { width: min(1040px, 100%); min-height: 610px; display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden; border: 1px solid rgba(255,255,255,.8); border-radius: 30px; background: white; box-shadow: 0 30px 90px rgba(48,58,105,.16); }
.login-visual { position: relative; padding: 58px; overflow: hidden; color: white; background: linear-gradient(145deg, #3448c4 0%, #6173ea 58%, #7586f3 100%); }
.login-visual::before, .login-visual::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; }
.login-visual::before { width: 430px; height: 430px; right: -230px; bottom: -150px; }
.login-visual::after { width: 280px; height: 280px; right: -130px; bottom: -70px; }
.login-logo { width: 50px; height: 50px; margin-bottom: 60px; border: 1px solid rgba(255,255,255,.25); border-radius: 15px; background: rgba(255,255,255,.13); box-shadow: none; }
.login-visual .eyebrow { color: #cdd4ff; }
.login-visual h1 { max-width: 440px; font-size: clamp(38px, 5vw, 55px); }
.login-visual > p:not(.eyebrow) { max-width: 420px; color: #dce1ff; line-height: 1.6; }
.mini-calendar { position: absolute; right: 38px; bottom: 40px; left: 58px; padding: 17px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; border: 1px solid rgba(255,255,255,.16); border-radius: 16px; background: rgba(255,255,255,.09); backdrop-filter: blur(6px); }
.mini-calendar span { color: #cfd5ff; font-size: 8px; text-align: center; }
.mini-calendar i { height: 32px; border-radius: 8px; background: rgba(255,255,255,.06); }
.mini-calendar i.selected { display: grid; place-items: center; background: white; color: var(--blue); font-size: 11px; font-style: normal; font-weight: 800; }
.login-form { padding: 70px 62px; display: flex; flex-direction: column; justify-content: center; }
.login-form h2 { font-size: 31px; }
.login-form .muted { margin-bottom: 26px; line-height: 1.6; }
.setup-note { margin: 0 0 12px; padding: 13px 15px; border: 1px solid #ead69b; border-radius: 12px; color: #79540e; background: var(--amber-soft); font-size: 12px; }
.setup-note.danger { color: #9e3242; border-color: #f0bdc5; background: var(--red-soft); }
.setup-note p { margin: 5px 0 0; line-height: 1.5; }
.setup-note code { overflow-wrap: anywhere; }
.google-button { height: 52px; display: flex; align-items: center; justify-content: center; gap: 12px; border: 1px solid #dcdfe7; border-radius: 13px; background: white; box-shadow: 0 6px 18px rgba(35,43,70,.07); font-size: 14px; font-weight: 700; }
.google-button:hover { border-color: #c3c8d5; background: #fafbfc; }
.google-button svg { width: 21px; }
.google-button.disabled { opacity: .45; pointer-events: none; }
.privacy { margin-top: 18px; color: #9aa0ad; font-size: 10px; text-align: center; }

.sync-panel { margin-bottom: 22px; padding: 24px; }
.sync-panel .section-heading p:not(.eyebrow) { max-width: 820px; margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.sync-form { display: grid; grid-template-columns: minmax(260px, 1fr) auto auto; align-items: end; gap: 14px; }
.sync-form .check { margin: 0 0 12px; }
.sync-meta { margin-top: 15px; padding-top: 13px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.sync-results { grid-template-columns: repeat(7, 1fr); }
.sync-warnings { margin-top: 14px; padding: 10px 14px; border-radius: 12px; color: #8b5d0c; background: var(--amber-soft); font-size: 12px; }
.sync-warnings p { margin: 4px 0; }
.audit-filters { flex-wrap: wrap; }
.audit-filters select { min-width: 165px; }
.inline-field { flex-direction: row; align-items: center; }
.inline-field input { width: 145px; }
.audit-action { color: var(--blue); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; font-weight: 700; }
.audit-details summary { color: var(--blue); cursor: pointer; font-size: 11px; }
.audit-details pre { max-width: 480px; max-height: 260px; padding: 12px; overflow: auto; border-radius: 10px; background: #f2f4f8; font-size: 10px; white-space: pre-wrap; }
.nowrap { white-space: nowrap; }
.pagination { padding: 16px; display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--line); }
.pagination a { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: var(--muted); background: var(--canvas); font-size: 11px; font-weight: 700; }
.pagination a.active { color: white; background: var(--blue); }
.audit-cleanup { margin-top: 20px; padding: 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.audit-cleanup p:not(.eyebrow) { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.audit-cleanup form { display: flex; gap: 10px; }
.audit-cleanup select { min-height: 43px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: white; }

@media (max-width: 980px) {
    .topbar { grid-template-columns: auto 1fr auto; padding: 0 20px; }
    .brand span:last-child, .account-copy { display: none; }
    .nav { overflow-x: auto; justify-self: stretch; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid, .detail-grid { grid-template-columns: 1fr; }
    .sync-results { grid-template-columns: repeat(4, 1fr); }
    .login-card { grid-template-columns: 1fr; }
    .login-visual { display: none; }
}

@media (max-width: 660px) {
    .shell { width: min(100% - 24px, 1320px); padding-top: 18px; }
    .topbar { height: auto; min-height: 68px; grid-template-columns: auto 1fr auto; }
    .nav { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; height: 58px; justify-content: space-around; border-top: 1px solid var(--line); background: white; }
    .nav a { padding: 0 9px; font-size: 11px; }
    .nav a.active::after { top: 0; bottom: auto; }
    .hero-upload { padding: 20px; }
    .hero-heading { display: block; }
    .hero-badge { display: none; }
    .drop-zone { min-height: 210px; padding: 24px 14px; }
    .upload-controls, .page-heading, .filters { align-items: stretch; flex-direction: column; }
    .sync-form { grid-template-columns: 1fr; }
    .sync-form .check { margin: 0; }
    .audit-cleanup, .audit-cleanup form { align-items: stretch; flex-direction: column; }
    .button-large, .calendar-select, .filters select { width: 100%; }
    .stats-grid, .result-grid, .sync-results { grid-template-columns: repeat(2, 1fr); }
    .calendar-card { grid-template-columns: 5px 1fr; }
    .calendar-actions { grid-column: 2; flex-wrap: wrap; }
    .login-form { padding: 42px 28px; }
    .auth-shell { padding: 16px; }
    dl > div { grid-template-columns: 1fr; gap: 5px; }
    body { padding-bottom: 58px; }
}
