:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #eef3f8;
  --text: #15181d;
  --muted: #687386;
  --line: #dce3ec;
  --primary: #0064ff;
  --primary-strong: #0047c7;
  --success: #0a9b6b;
  --danger: #e54242;
  --warning: #b7791f;
  --shadow: 0 18px 42px rgba(22, 34, 51, 0.12);
}

[data-theme="dark"] {
  --bg: #121417;
  --surface: #1b2027;
  --surface-soft: #252c35;
  --text: #f4f7fb;
  --muted: #a2adbd;
  --line: #333c49;
  --primary: #4c8dff;
  --primary-strong: #78a8ff;
  --success: #38c793;
  --danger: #ff6b6b;
  --warning: #f2bd57;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 240px;
  padding: 24px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand,
.nav a,
.text-link {
  color: inherit;
  text-decoration: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 900;
}

.brand-mark.large {
  width: 48px;
  height: 48px;
  font-size: 24px;
}

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

.nav a {
  padding: 11px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
}

.nav a.active,
.nav a:hover {
  background: var(--surface-soft);
  color: var(--text);
}

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

.main {
  flex: 1;
  min-width: 0;
  padding: 32px;
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 28px;
  align-items: stretch;
}

.auth-copy,
.auth-form,
.toolbar,
.grid-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-copy {
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-copy h1,
.topbar h1 {
  margin: 12px 0 8px;
  font-size: 32px;
  letter-spacing: 0;
}

.auth-copy p,
.eyebrow,
.grid-meta span {
  color: var(--muted);
}

.auth-form {
  padding: 32px;
  display: grid;
  gap: 16px;
}

.auth-form h2 {
  margin: 0;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.topbar,
.toolbar,
.grid-meta,
.pager,
.filters,
.upload-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.toolbar {
  justify-content: space-between;
  padding: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.upload-box,
.filters {
  flex-wrap: wrap;
}

.filters input {
  width: min(360px, 70vw);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  padding: 0 18px;
  background: var(--primary);
  color: white;
}

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

.secondary-button {
  padding: 0 16px;
  background: var(--text);
  color: var(--surface);
}

.ghost-button,
.icon-button {
  padding: 0 14px;
  background: var(--surface-soft);
  color: var(--text);
}

.icon-button {
  width: 42px;
  padding: 0;
}

.grid-panel {
  overflow: hidden;
}

.grid-meta {
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

.alv-grid {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.alv-grid th,
.alv-grid td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.alv-grid th {
  position: sticky;
  top: 0;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  z-index: 1;
}

.alv-grid tr:hover td {
  background: var(--surface-soft);
}

.check-cell {
  width: 48px;
}

.editable {
  min-width: 180px;
}

.url-cell {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  background: var(--surface-soft);
  color: var(--muted);
}

.status.downloaded {
  color: var(--success);
}

.status.failed {
  color: var(--danger);
}

.pager {
  justify-content: center;
  padding: 16px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 48px));
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  box-shadow: var(--shadow);
  font-weight: 800;
}

.flash {
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.flash.error {
  color: var(--danger);
}

.flash.success {
  color: var(--success);
}

@media (max-width: 760px) {
  .app-shell,
  .auth-panel {
    display: block;
  }

  .sidebar {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .main {
    padding: 18px;
  }

  .auth-copy {
    margin-bottom: 18px;
    padding: 28px;
  }

  .auth-form {
    padding: 24px;
  }

  .topbar,
  .toolbar,
  .filters,
  .upload-box {
    align-items: stretch;
  }

  .topbar,
  .toolbar {
    flex-direction: column;
  }

  .filters input {
    width: 100%;
  }
}
