:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef3f6;
  --text: #172026;
  --muted: #65717b;
  --line: #dbe2e7;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --shadow: 0 16px 45px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
}

.login-visual {
  min-height: 100vh;
  padding: clamp(32px, 7vw, 96px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(135deg, #123c43 0%, #0f766e 48%, #c7d7c8 100%);
  color: #fff;
}

.brand-mark,
.brand-icon,
.icon-pill {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
}

.brand-mark {
  background: rgba(255, 255, 255, 0.16);
}

.login-visual h1 {
  max-width: 760px;
  margin: 8px 0 16px;
  font-size: clamp(2.2rem, 5vw, 5.2rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.lead {
  max-width: 560px;
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 1.08rem;
  line-height: 1.6;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-visual .eyebrow {
  color: rgba(255, 255, 255, 0.72);
}

.login-panel {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card,
.filter-panel,
.table-panel,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(100%, 430px);
  padding: 28px;
}

.form-heading {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.form-heading h2,
.topbar h1,
.table-heading h2 {
  margin: 0;
}

.form-heading p,
.table-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.icon-pill {
  flex: 0 0 auto;
  background: var(--surface-2);
  color: var(--accent);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.field small,
.alert-error {
  color: var(--danger);
}

.alert {
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 8px;
  background: #fff1f0;
  border: 1px solid #ffd8d4;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px;
  background: #172026;
  color: #fff;
}

.brand-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-row small {
  display: block;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.62);
}

.brand-icon {
  background: rgba(255, 255, 255, 0.1);
  color: #72d6c9;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-list a,
.logout-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 10px;
  color: rgba(255, 255, 255, 0.76);
}

.nav-list a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.logout-link {
  margin-top: auto;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar,
.table-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 22px;
}

.topbar h1 {
  margin-top: 4px;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  letter-spacing: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 800;
}

.filter-panel {
  padding: 18px;
  margin-bottom: 18px;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(100px, 0.6fr) minmax(180px, 1fr) auto auto;
  align-items: end;
  gap: 14px;
}

.field.compact {
  margin: 0;
}

.query-button {
  width: auto;
  min-width: 148px;
}

.process-button {
  min-width: 132px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  padding: 18px;
}

.metric-card span {
  color: var(--muted);
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

.table-panel {
  overflow: hidden;
}

.table-heading {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  gap: 10px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 42px;
  height: 42px;
}

.responsive-table {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 0.92rem;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
}

.file-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  min-width: 42px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface-2);
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.badge-link {
  border: 1px solid rgba(15, 118, 110, 0.22);
}

.badge-link:hover {
  background: var(--accent);
  color: #fff;
}

.error-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.error-panel {
  width: min(100%, 560px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.error-code {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--accent-dark);
  font-weight: 900;
}

.error-panel h1 {
  margin: 18px 0 10px;
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  letter-spacing: 0;
}

.error-panel p {
  margin: 0 auto 24px;
  max-width: 440px;
  color: var(--muted);
  line-height: 1.6;
}

.inline-button {
  width: auto;
}

@media (max-width: 920px) {
  .login-shell,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 38vh;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .nav-list {
    grid-auto-flow: column;
    margin-left: auto;
  }

  .logout-link {
    margin-top: 0;
  }

  .filter-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .query-button,
  .process-button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .login-panel,
  .workspace {
    padding: 16px;
  }

  .login-visual {
    padding: 28px 20px;
  }

  .auth-card {
    padding: 20px;
  }

  .topbar,
  .table-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-pill {
    width: 100%;
    justify-content: center;
  }

  .sidebar {
    padding: 14px;
  }

  .brand-row small,
  .nav-list span,
  .logout-link span {
    display: none;
  }
}
