:root {
  color-scheme: dark;
  --bg: #05080b;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-strong: rgba(255, 255, 255, 0.095);
  --field: rgba(0, 0, 0, 0.28);
  --border: rgba(214, 232, 255, 0.13);
  --border-strong: rgba(94, 234, 212, 0.34);
  --text: #eef7fb;
  --muted: #8ea2b8;
  --cyan: #67e8f9;
  --silver: #d7e2ea;
  --green: #86efac;
  --amber: #fcd34d;
  --rose: #fda4af;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 6% -8%, rgba(103, 232, 249, 0.2), transparent 28rem),
    radial-gradient(circle at 88% 4%, rgba(214, 226, 234, 0.11), transparent 24rem),
    linear-gradient(145deg, #05080b, #071014 62%, #020405);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.auth-locked {
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px 28px;
}

.login-screen {
  min-height: 100svh;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: clamp(14px, 3vh, 22px);
  overflow-x: hidden;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
}

.login-panel {
  width: min(720px, 100%);
  border: 1px solid rgba(214, 232, 255, 0.18);
  border-radius: 28px;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.045)),
    rgba(8, 18, 27, 0.9);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.44);
  backdrop-filter: blur(20px);
  padding: clamp(22px, 4vw, 44px);
}

.login-brand {
  margin-bottom: clamp(18px, 3vh, 28px);
  text-align: center;
}

.login-brand h1 {
  margin-bottom: 10px;
  font-size: clamp(32px, 6vw, 48px);
}

.login-brand p:last-child {
  margin-bottom: 0;
  color: #9eb2c7;
}

.login-actions {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.auth-card {
  width: min(600px, 100%);
  margin: 0 auto;
  border: 1px solid rgba(214, 232, 255, 0.17);
  border-radius: 24px;
  background: rgba(7, 17, 25, 0.68);
  padding: clamp(20px, 4vw, 36px);
}

.auth-card h2 {
  margin-bottom: clamp(18px, 3vh, 28px);
  color: #aebdd1;
  font-size: clamp(22px, 4vw, 28px);
  font-weight: 700;
  text-align: center;
}

.google-shell {
  display: grid;
  min-height: 76px;
  place-items: center;
  border: 2px solid rgba(214, 232, 255, 0.22);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.07);
}

.auth-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: clamp(12px, 3vw, 22px);
  align-items: center;
  margin: clamp(20px, 4vh, 34px) 0;
  color: #6f839a;
  font-size: clamp(18px, 3vw, 24px);
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  background: rgba(214, 232, 255, 0.14);
}

.email-login-button {
  width: 100%;
  min-height: 70px;
  border: 2px solid rgba(214, 232, 255, 0.12);
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.16);
  color: #8195aa;
  font-size: clamp(22px, 4vw, 28px);
  font-weight: 700;
}

.email-login-button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.auth-terms {
  margin: clamp(18px, 3vh, 28px) 0 0;
  color: #697d93;
  font-size: 15px;
  text-align: center;
}

.auth-terms a,
.forgot-link,
.login-footer a {
  color: var(--cyan);
  font-weight: 800;
  text-decoration: none;
}

.forgot-link {
  display: block;
  margin-top: clamp(16px, 3vh, 24px);
  color: #657a92;
  text-align: center;
}

.login-message {
  min-height: 22px;
  margin: 14px auto 0;
  color: var(--amber);
  font-size: 13px;
  text-align: center;
}

.login-meta {
  margin: 6px auto 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.login-footer {
  text-align: center;
}

.login-footer p {
  margin-bottom: 10px;
  color: #7d91a7;
  font-size: clamp(16px, 3vw, 22px);
}

.login-footer small {
  color: #3d5067;
  font-size: clamp(13px, 2.6vw, 16px);
}

.session-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.user-badge {
  max-width: 260px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--silver);
  padding: 8px 10px;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-badge {
  border: 1px solid rgba(103, 232, 249, 0.28);
  border-radius: 999px;
  color: var(--cyan);
  padding: 8px 10px;
  font-size: 12px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0 18px;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  color: #f8fdff;
  font-size: clamp(30px, 4.8vw, 46px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  color: #f8fdff;
  font-size: 18px;
}

p {
  color: var(--muted);
  line-height: 1.7;
}

.subtitle {
  max-width: 620px;
  margin-bottom: 0;
}

.icon-button,
.primary-button,
.ghost-button,
.task-form button {
  min-height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: rgba(103, 232, 249, 0.12);
  color: #dffbff;
  padding: 10px 14px;
}

.primary-button {
  background: linear-gradient(135deg, rgba(103, 232, 249, 0.24), rgba(214, 226, 234, 0.12));
  font-weight: 800;
}

.ghost-button {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.045);
  color: var(--silver);
}

.ghost-button.danger {
  border-color: rgba(253, 164, 175, 0.36);
  color: var(--rose);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.metrics article,
.modules-panel,
.records-panel,
.editor-panel,
.tasks-panel,
.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(18px);
}

.metrics article {
  padding: 16px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  display: block;
  margin-top: 10px;
  color: var(--cyan);
  font-size: 34px;
  line-height: 1;
}

.flow {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.flow span {
  min-height: 42px;
  display: grid;
  place-items: center;
  background: rgba(3, 8, 12, 0.72);
  color: var(--silver);
  font-size: 13px;
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 380px;
  gap: 14px;
  align-items: start;
}

.modules-panel,
.records-panel,
.editor-panel,
.tasks-panel {
  padding: 16px;
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title.compact {
  align-items: center;
}

.section-title p {
  margin-bottom: 0;
  font-size: 13px;
}

.section-title span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
}

.modules-grid {
  display: grid;
  gap: 8px;
}

.module-card {
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  padding: 10px;
  text-align: left;
}

.module-card.active {
  border-color: var(--border-strong);
  background: rgba(103, 232, 249, 0.11);
  box-shadow: inset 0 0 0 1px rgba(103, 232, 249, 0.09);
}

.module-index {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(103, 232, 249, 0.25);
  border-radius: 8px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
}

.module-card strong,
.module-card small {
  display: block;
}

.module-card small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px auto;
  gap: 10px;
  margin-bottom: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(103, 232, 249, 0.08);
}

textarea {
  resize: vertical;
}

.record-list {
  display: grid;
  gap: 10px;
}

.record-card {
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
}

.record-main {
  width: 100%;
  display: grid;
  gap: 12px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 14px;
  text-align: left;
}

.record-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.record-title-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.record-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.record-fields span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--silver);
  font-size: 13px;
}

.record-fields small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.success {
  border-color: rgba(134, 239, 172, 0.32);
  color: var(--green);
  background: rgba(34, 197, 94, 0.1);
}

.status-pill.warning {
  border-color: rgba(252, 211, 77, 0.32);
  color: var(--amber);
  background: rgba(245, 158, 11, 0.1);
}

.status-pill.danger {
  border-color: rgba(253, 164, 175, 0.34);
  color: var(--rose);
  background: rgba(244, 63, 94, 0.1);
}

.status-pill.neutral {
  color: var(--silver);
  background: rgba(255, 255, 255, 0.06);
}

.empty-state {
  margin: 20px 0 0;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  text-align: center;
}

.module-insights {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.module-insights article {
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  padding: 12px;
}

.module-insights span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.module-insights strong {
  display: block;
  margin-top: 6px;
  color: var(--cyan);
  font-size: 24px;
  line-height: 1;
}

.side-stack {
  display: grid;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
}

.field-wide {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.form-message {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.form-message.error {
  color: var(--rose);
}

.form-message.success {
  color: var(--green);
}

.task-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task {
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  padding: 12px;
}

.task strong {
  display: block;
  margin-bottom: 6px;
}

.task span {
  color: var(--muted);
  font-size: 12px;
}

.offline {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.panel {
  width: min(420px, 100%);
  padding: 24px;
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: rgba(103, 232, 249, 0.12);
  color: #dffbff;
  padding: 10px 14px;
  text-decoration: none;
}

.form-inline-button {
  margin-left: 6px;
  padding: 2px 8px;
  font-size: 11px;
  background: rgba(103, 232, 249, 0.1);
  border: 1px solid rgba(103, 232, 249, 0.28);
  border-radius: 4px;
  color: var(--cyan);
  cursor: pointer;
  vertical-align: middle;
  line-height: 1.6;
}

.form-inline-button:hover {
  background: rgba(103, 232, 249, 0.2);
}

.field-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .side-stack {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) 360px;
  }
}

@media (max-width: 820px) {
  .login-screen {
    padding-left: 14px;
    padding-right: 14px;
  }

  .login-panel {
    border-radius: 20px;
  }

  .auth-card {
    border-radius: 18px;
  }

  .google-shell,
  .email-login-button {
    min-height: 62px;
    border-radius: 14px;
  }

  .topbar {
    display: grid;
  }

  .session-actions {
    justify-content: start;
    flex-wrap: wrap;
  }

  .metrics,
  .workspace,
  .side-stack,
  .toolbar,
  .module-insights,
  .record-fields,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .login-panel {
    padding: 18px;
  }

  .login-brand h1 {
    font-size: 30px;
  }

  .auth-card {
    padding: 16px;
  }

  .auth-divider {
    font-size: 15px;
  }

  .email-login-button {
    font-size: 18px;
  }

  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .record-title-row,
  .section-title {
    display: grid;
  }
}
