@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --background: #0f172a;
  --surface: #192134;
  --surface-soft: #131d31;
  --foreground: #f8fafc;
  --muted: #a8b3c5;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --accent: #10b981;
  --accent-dark: #047857;
  --danger: #ef4444;
  --warning: #f59e0b;
  --focus: #93c5fd;
  --radius: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }
html { color-scheme: dark; scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--background);
  color: var(--foreground);
  font: 400 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a { color: inherit; }

.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 10px 14px; border-radius: 8px; background: #fff; color: #0f172a; font-weight: 700; text-decoration: none; transform: translateY(-150%); transition: transform .15s ease; }
.skip-link:focus { transform: translateY(0); outline: 3px solid var(--focus); outline-offset: 2px; }

.shell { width: min(1180px, calc(100% - 32px)); margin-inline: auto; }
.main-content { padding-block: 36px 56px; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 5px; color: #6ee7b7; font-size: .75rem; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.75rem, 4vw, 2.35rem); line-height: 1.14; letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 1.05rem; line-height: 1.3; letter-spacing: -.02em; }

.topbar { position: sticky; z-index: 10; top: 0; border-bottom: 1px solid var(--border); background: rgba(15, 23, 42, .92); backdrop-filter: blur(16px); }
.topbar-inner { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.brand strong, .brand small { display: block; }
.brand strong { line-height: 1.1; letter-spacing: -.02em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: .72rem; }
.brand-mark { width: 42px; height: 42px; display: inline-grid; place-items: center; flex: 0 0 auto; border: 1px solid rgba(16, 185, 129, .35); border-radius: 11px; background: rgba(16, 185, 129, .12); color: #6ee7b7; }
.brand-mark svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.connection { min-height: 34px; display: inline-flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: .78rem; font-weight: 600; }
.connection > span:first-child, .status-pill > span:first-child { width: 7px; height: 7px; display: inline-block; flex: 0 0 7px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 3px rgba(245, 158, 11, .12); }
.connection.is-online > span:first-child, .status-success > span:first-child { background: var(--accent); box-shadow: 0 0 0 3px rgba(16, 185, 129, .13); }

.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading form { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.date-input { width: auto; min-height: 44px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.page-heading p:last-child { max-width: 700px; margin-bottom: 0; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.summary-card { min-width: 0; display: flex; align-items: center; gap: 13px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 25px rgba(0, 0, 0, .12); }
.summary-card strong, .summary-card span { display: block; }
.summary-card strong { overflow: hidden; font-size: 1.05rem; text-overflow: ellipsis; white-space: nowrap; }
.summary-card div > span { margin-top: 2px; color: var(--muted); font-size: .76rem; }
.summary-icon, .site-icon { width: 38px; height: 38px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 9px; background: rgba(147, 197, 253, .1); color: #93c5fd; }
.summary-icon svg, .site-icon svg, .button svg, .icon-link svg, .empty-state svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

.panel { margin-bottom: 18px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel-header { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel-meta { color: var(--muted); font-size: .75rem; }
.dashboard-tabs { position: sticky; z-index: 9; top: 68px; display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-soft); }
.dashboard-tab { min-height: 44px; flex: 0 0 auto; padding: 0 16px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.dashboard-tab:hover { background: rgba(255, 255, 255, .05); color: var(--foreground); }
.dashboard-tab:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.dashboard-tab.is-active { border-color: var(--border); background: var(--surface); color: var(--foreground); box-shadow: 0 3px 10px rgba(0, 0, 0, .12); }
.dashboard-tab-panel { min-width: 0; }
.dashboard-tab-panel[hidden] { display: none; }
.dashboard-tab-panel .panel[id] { scroll-margin-top: 150px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.settings-grid #notifications { grid-column: 1 / -1; }
.site-list, .history-list { display: grid; }
.site-row { position: relative; display: grid; grid-template-columns: 42px minmax(180px, 1fr) auto auto; align-items: center; gap: 14px; min-height: 73px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.site-row:last-child, .history-row:last-child { border-bottom: 0; }
.site-info { min-width: 0; }
.site-info strong, .site-info span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-info strong { font-size: .9rem; }
.site-info span { margin-top: 3px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .73rem; }
.row-error { grid-column: 2 / -1; margin: -8px 0 4px; color: #fca5a5; font-size: .75rem; }
.status-pill { min-height: 29px; display: inline-flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--border); border-radius: 999px; color: #dbe5f3; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.status-error > span:first-child, .status-indicator.status-error { background: var(--danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, .12); }
.status-warning > span:first-child { background: var(--warning); }

.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 16px; border: 1px solid transparent; border-radius: 9px; font-weight: 700; font-size: .82rem; line-height: 1; text-decoration: none; cursor: pointer; transition: background-color .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease, opacity .2s ease; }
.button:hover { box-shadow: 0 6px 16px rgba(0, 0, 0, .18); }
.button:focus-visible, .input:focus-visible, .icon-link:focus-visible, .brand:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.button:disabled { cursor: not-allowed; opacity: .42; box-shadow: none; }
.button-primary { background: var(--accent); color: #052e22; }
.button-primary:hover:not(:disabled) { background: #34d399; }
.button-secondary { border-color: var(--border-strong); background: rgba(255, 255, 255, .035); color: var(--foreground); }
.button-secondary:hover:not(:disabled), .button-quiet:hover { background: rgba(255, 255, 255, .08); }
.button-danger { border-color: rgba(239, 68, 68, .35); background: rgba(239, 68, 68, .1); color: #fecaca; }
.button-quiet { min-height: 38px; border-color: transparent; background: transparent; color: var(--muted); }
.button-full { width: 100%; }
.button-group { display: flex; flex-wrap: wrap; gap: 10px; padding: 18px; }
.button-group form { flex: 1; }
.button-group .button { width: 100%; }
.panel-description { margin: 0; padding: 0 18px 14px; color: var(--muted); font-size: .82rem; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .75fr); gap: 18px; align-items: start; }
.history-row { min-height: 66px; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.status-indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.history-row strong, .history-row span, .history-row time { display: block; }
.history-row > div:nth-child(2) { min-width: 0; }
.history-row > div:nth-child(2) strong { font-size: .84rem; }
.history-row > div:nth-child(2) span { overflow: hidden; margin-top: 2px; color: var(--muted); font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.history-actions { display: flex; align-items: center; gap: 14px; }
.history-side { text-align: right; }
.button-download { min-height: 44px; white-space: nowrap; }
.history-side strong { font-size: .76rem; }
.history-side time { margin-top: 3px; color: var(--muted); font-size: .67rem; }
.empty-state { min-height: 240px; display: grid; place-items: center; align-content: center; gap: 8px; padding: 32px; color: var(--muted); text-align: center; }
.empty-state svg { width: 32px; height: 32px; margin-bottom: 6px; }
.empty-state strong { color: var(--foreground); }
.empty-state span { font-size: .82rem; }
.progress-content { display: grid; gap: 8px; padding: 18px; color: var(--muted); font-size: .8rem; }
.progress-content strong { color: var(--foreground); font-size: .9rem; }
.progress-panel #progress-status { flex: 0 0 auto; }
.progress-track { height: 8px; overflow: hidden; margin-top: 5px; border-radius: 999px; background: rgba(255, 255, 255, .08); }
.progress-track span { height: 100%; display: block; border-radius: inherit; background: linear-gradient(90deg, #10b981, #60a5fa); transition: width .35s ease; }
.progress-content .row-error { margin: 0; }
.operations-grid { margin-top: 18px; }
.ops-copy { padding: 18px; color: var(--muted); font-size: .8rem; }
.ops-copy p:last-child { margin-bottom: 0; }
.ops-copy strong { color: var(--foreground); }
.ops-copy a { color: #93c5fd; }
.ops-copy pre { overflow-x: auto; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #0d1628; color: #dbeafe; font-size: .72rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.ops-copy code { color: #dbeafe; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .72rem; }
.check-label { display: flex !important; align-items: center; gap: 9px; }
.check-label input { width: 18px; height: 18px; accent-color: var(--accent); }
.history-side small { display: block; margin-top: 3px; color: var(--muted); font-size: .65rem; white-space: nowrap; }
.history-details { grid-column: 2 / -1; color: var(--muted); font-size: .72rem; }
.history-details summary { width: fit-content; cursor: pointer; color: #93c5fd; }
.history-details p { margin: 5px 0; color: #fecaca; overflow-wrap: anywhere; }
.event-list { display: grid; }
.event-row { display: grid; grid-template-columns: 100px minmax(130px, .7fr) minmax(0, 1.5fr); gap: 5px 14px; padding: 12px 18px; border-bottom: 1px solid var(--border); font-size: .74rem; }
.event-row:last-child { border-bottom: 0; }
.event-row time, .event-row span, .event-row small { color: var(--muted); }
.event-row strong { overflow-wrap: anywhere; }
.event-row small { grid-column: 2 / -1; }
.event-row.event-error span { color: #fecaca; }

.drive-folder { display: grid; grid-template-columns: 42px 1fr 44px; align-items: center; gap: 12px; padding: 18px; border-bottom: 1px solid var(--border); }
.drive-folder strong, .drive-folder span { display: block; }
.drive-folder strong { font-size: .86rem; }
.drive-folder div > span { margin-top: 3px; color: var(--muted); font-size: .72rem; }
.icon-link { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 9px; color: var(--muted); transition: background-color .2s ease, color .2s ease; }
.icon-link:hover { background: rgba(255, 255, 255, .07); color: var(--foreground); }
.compact-form { padding: 18px; border-bottom: 1px solid var(--border); }
.form-stack { display: grid; gap: 13px; }
.form-stack label { display: block; margin-bottom: 6px; color: #d9e2ef; font-size: .78rem; font-weight: 600; }
.input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: #0d1628; color: var(--foreground); transition: border-color .2s ease, box-shadow .2s ease; }
.input:hover { border-color: rgba(255, 255, 255, .28); }
.input:focus { border-color: #60a5fa; outline: 0; box-shadow: 0 0 0 3px rgba(96, 165, 250, .18); }
.input-small { max-width: 150px; }
.helper { margin: 0; color: var(--muted); font-size: .73rem; overflow-wrap: anywhere; }
.helper code { color: #cbd5e1; }
.success-copy { margin: 0; padding: 18px 18px 0; color: #a7f3d0; font-size: .82rem; }

.alert { margin-bottom: 20px; padding: 13px 15px; border: 1px solid; border-radius: 10px; font-size: .84rem; }
.alert-success { border-color: rgba(16, 185, 129, .35); background: rgba(16, 185, 129, .1); color: #a7f3d0; }
.alert-error { border-color: rgba(239, 68, 68, .4); background: rgba(239, 68, 68, .11); color: #fecaca; }

.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .72rem; }
.footer .shell { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.login-page { min-height: 100vh; background: radial-gradient(circle at 50% 0, rgba(30, 58, 95, .55), transparent 42%), var(--background); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 420px); padding: 34px; border: 1px solid var(--border); border-radius: 16px; background: rgba(25, 33, 52, .94); box-shadow: var(--shadow); }
.login-card .brand-mark { margin-bottom: 22px; }
.login-card h1 { font-size: 1.65rem; }
.login-card > .muted { margin-bottom: 24px; }

@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .shell { width: min(100% - 24px, 1180px); }
  .main-content { padding-block: 26px 42px; }
  .connection { display: none; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading form, .page-heading .button { width: 100%; }
  .page-heading form .date-input { width: 100%; }
  .summary-grid { grid-template-columns: 1fr; }
  .dashboard-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .dashboard-tab { min-width: 0; padding-inline: 8px; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid #notifications { grid-column: auto; }
  .site-row { grid-template-columns: 38px minmax(0, 1fr) auto; gap: 10px; padding: 13px 14px; }
  .site-row form { grid-column: 2 / -1; }
  .site-row .button { width: 100%; }
  .site-row > .status-pill { justify-self: end; }
  .progress-panel .panel-header { flex-wrap: wrap; }
  .row-error { grid-column: 2 / -1; margin-top: 0; }
  .panel-header { align-items: flex-start; }
  .panel-meta { text-align: right; }
  .history-row { grid-template-columns: 8px minmax(0, 1fr); padding-inline: 14px; }
  .history-actions { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
  .history-side { flex: 1 1 180px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 12px; text-align: left; }
  .button-download { flex: 0 0 auto; }
  .history-side small { white-space: normal; overflow-wrap: anywhere; }
  .event-row { grid-template-columns: 1fr; gap: 4px; padding-inline: 14px; }
  .event-row small { grid-column: auto; }
  .history-details { grid-column: 2 / -1; }
  .footer .shell { align-items: flex-start; flex-direction: column; justify-content: center; }
  .login-card { padding: 26px 22px; }
}

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