:root {
  --black: #1d1d1b;
  --black-soft: #282826;
  --blue: #1c9bd7;
  --yellow: #ffdb05;
  --red: #e1081a;
  --green: #16835f;
  --canvas: #f3f4f5;
  --surface: #ffffff;
  --surface-soft: #f8f9fa;
  --text: #1f2428;
  --muted: #6f777d;
  --line: #e2e5e7;
  --line-dark: rgba(255, 255, 255, 0.1);
  --shadow: 0 10px 30px rgba(24, 31, 35, 0.06);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--canvas);
  font-family: "Montserrat", "Avenir Next", "Helvetica Neue", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
a { color: inherit; }

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 26px 18px 22px;
  color: #fff;
  background: var(--black);
  border-right: 1px solid #121211;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 56px;
  padding: 0 8px 24px;
  border-bottom: 1px solid var(--line-dark);
}

.brand img { width: 48px; height: 48px; object-fit: contain; }
.brand strong, .brand span { display: block; line-height: 1.1; }
.brand strong { font-size: 0.95rem; font-weight: 800; letter-spacing: 0.02em; }
.brand span { margin-top: 4px; color: #aeb4b8; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; }

.nav { display: grid; gap: 6px; margin-top: 24px; }
.nav-item {
  position: relative;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 8px 11px;
  color: #bfc4c6;
  border-radius: 8px;
  text-decoration: none;
  transition: color 140ms ease, background 140ms ease;
}
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.nav-item.is-active { color: #fff; background: rgba(28, 155, 215, 0.15); }
.nav-item.is-active::before { position: absolute; left: -18px; width: 3px; height: 28px; content: ""; background: var(--blue); border-radius: 0 3px 3px 0; }
.nav-icon { display: grid; place-items: center; width: 26px; height: 26px; color: var(--blue); background: rgba(28, 155, 215, 0.12); border-radius: 6px; font-size: 0.58rem; font-weight: 900; }
.folder-icon { position: relative; background: rgba(255, 255, 255, 0.06); }
.folder-icon::before { width: 13px; height: 9px; content: ""; border: 1.5px solid currentColor; border-radius: 2px; }
.folder-icon::after { position: absolute; top: 7px; left: 6px; width: 6px; height: 3px; content: ""; border: 1.5px solid currentColor; border-bottom: 0; border-radius: 2px 2px 0 0; }
.external { color: #737a7d; }

.sidebar-meta { display: grid; gap: 5px; margin-top: auto; padding: 18px 8px 0; color: #81888b; border-top: 1px solid var(--line-dark); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; }
.sidebar-meta strong { color: #c7cbcd; font-size: 0.7rem; }
.brand-bars { display: flex; gap: 4px; height: 4px; margin-bottom: 10px; }
.brand-bars i { width: 22px; height: 4px; border-radius: 4px; }
.brand-bars i:nth-child(1) { background: var(--red); }
.brand-bars i:nth-child(2) { background: var(--blue); }
.brand-bars i:nth-child(3) { background: var(--yellow); }

.workspace { min-width: 0; }
.topbar { display: flex; justify-content: space-between; gap: 24px; align-items: center; min-height: 88px; padding: 18px clamp(24px, 4vw, 54px); background: rgba(255, 255, 255, 0.93); border-bottom: 1px solid var(--line); }
.breadcrumb { margin: 0 0 5px; color: var(--muted); font-size: 0.72rem; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.55rem; font-weight: 750; letter-spacing: -0.025em; }
h2 { margin: 3px 0 0; font-size: 1.08rem; font-weight: 750; letter-spacing: -0.012em; }

.topbar-status { display: flex; gap: 9px; align-items: center; }
.connection, .schedule-chip { display: inline-flex; gap: 8px; align-items: center; min-height: 34px; padding: 0 12px; color: var(--muted); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 7px; font-size: 0.7rem; font-weight: 650; }
.connection i { width: 7px; height: 7px; background: var(--green); border-radius: 50%; box-shadow: 0 0 0 3px rgba(22, 131, 95, 0.12); }
.connection.is-error i { background: var(--red); box-shadow: 0 0 0 3px rgba(225, 8, 26, 0.1); }
.logout-form { margin: 0; }
.logout-button { min-height: 34px; padding: 0 11px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: 0.7rem; font-weight: 700; cursor: pointer; }
.logout-button:hover { color: var(--black); border-color: #b9c1c5; }

.content { width: min(1220px, calc(100% - 48px)); margin: 0 auto; padding: 32px 0 48px; }
.work-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.7fr); gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.upload-card, .queue-card { padding: 24px; }
.card-header { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 20px; }
.card-header.compact { align-items: center; }
.card-label { color: var(--muted); font-size: 0.63rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.file-rule, .table-note { color: var(--muted); font-size: 0.7rem; }

.drop-zone { display: grid; place-items: center; min-height: 235px; padding: 30px; text-align: center; background: var(--surface-soft); border: 1.5px dashed #b9c1c5; border-radius: 10px; cursor: pointer; transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease; }
.drop-zone:hover, .drop-zone.is-dragging { background: #f3fafd; border-color: var(--blue); box-shadow: inset 0 0 0 1px rgba(28, 155, 215, 0.1); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 14px; color: var(--blue); background: rgba(28, 155, 215, 0.09); border-radius: 10px; }
.upload-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.drop-title { font-size: 0.95rem; font-weight: 750; }
.drop-help { margin-top: 6px; color: var(--muted); font-size: 0.76rem; }
.selected-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.selected-files span { max-width: 100%; padding: 6px 8px; overflow: hidden; color: #28576c; background: #eaf5fa; border-radius: 5px; font-size: 0.7rem; text-overflow: ellipsis; white-space: nowrap; }

.button { display: inline-flex; justify-content: center; gap: 12px; align-items: center; min-height: 46px; padding: 0 18px; border: 0; border-radius: 8px; font-weight: 750; cursor: pointer; transition: transform 140ms ease, background 140ms ease, opacity 140ms ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: 0.42; cursor: not-allowed; }
.button-primary { width: 100%; margin-top: 12px; color: #fff; background: var(--blue); }
.button-primary:hover:not(:disabled) { background: #168bc2; }
.button-dark { width: 100%; color: #fff; background: var(--black); }
.button-dark:hover:not(:disabled) { background: #050505; }
.message { min-height: 18px; margin-top: 10px; color: var(--muted); font-size: 0.74rem; line-height: 1.45; }
.message.is-success { color: var(--green); }
.message.is-warning { color: #8b6900; }
.message.is-error { color: var(--red); }

.live-dot { width: 8px; height: 8px; background: var(--green); border-radius: 50%; box-shadow: 0 0 0 4px rgba(22, 131, 95, 0.1); }
.queue-metric { display: grid; place-items: center; min-height: 214px; margin: 8px 0 16px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; text-align: center; }
.queue-metric strong { display: block; font-size: clamp(4.3rem, 9vw, 6.4rem); font-weight: 650; line-height: 0.9; letter-spacing: -0.08em; }
.queue-metric span { margin-top: -24px; color: var(--muted); font-size: 0.74rem; }
.queue-footer { display: grid; gap: 6px; margin-top: 18px; padding-top: 16px; color: var(--muted); border-top: 1px solid var(--line); font-size: 0.68rem; }
.queue-footer a { color: #176b92; font-weight: 700; text-decoration: none; }

.activity-card { margin-top: 20px; padding: 24px 24px 8px; }
.table-wrap { overflow-x: auto; margin: 0 -24px; }
table { width: 100%; border-collapse: collapse; font-size: 0.76rem; }
th, td { padding: 14px 18px; text-align: left; border-top: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); background: #fafbfb; font-size: 0.61rem; letter-spacing: 0.09em; text-transform: uppercase; }
.empty-row td { height: 92px; color: var(--muted); text-align: center; }
.status { display: inline-block; padding: 5px 8px; border-radius: 6px; font-size: 0.66rem; font-weight: 750; }
.status-completed { color: #0d6346; background: #dff2eb; }
.status-completed_with_errors { color: #7f5e00; background: #fff4cc; }
.status-failed { color: #a00614; background: #fbe3e5; }
.status-running { color: #176b92; background: #e1f2f9; }
.file-link { color: #176b92; font-weight: 700; text-decoration: none; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 82px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand img { width: 46px; height: 46px; }
  .brand div, .nav-item > span:not(.nav-icon), .sidebar-meta span, .sidebar-meta strong { display: none; }
  .nav-item { display: grid; grid-template-columns: 1fr; justify-items: center; padding-inline: 0; }
  .sidebar-meta { padding-inline: 0; }
  .brand-bars { justify-content: center; gap: 2px; }
  .brand-bars i { width: 12px; }
  .work-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { position: static; display: grid; grid-template-columns: auto 1fr; align-items: center; width: 100%; height: auto; padding: 10px 16px; }
  .brand { min-height: 42px; padding: 0 16px 0 0; border: 0; border-right: 1px solid var(--line-dark); }
  .brand img { width: 38px; height: 38px; }
  .nav { display: flex; margin: 0 0 0 12px; }
  .nav-item { width: 42px; min-height: 42px; }
  .nav-item.is-active::before, .sidebar-meta { display: none; }
  .topbar { align-items: flex-start; padding: 18px 18px 16px; }
  .topbar-status { align-items: flex-end; flex-direction: column; }
  .schedule-chip { display: none; }
  .content { width: calc(100% - 28px); padding-top: 16px; }
  .upload-card, .queue-card, .activity-card { padding: 18px; }
  .card-header { gap: 12px; }
  .file-rule, .table-note { display: none; }
  .drop-zone { min-height: 205px; padding: 22px; }
  .table-wrap { margin-inline: -18px; }
}

@media (prefers-reduced-motion: no-preference) {
  .upload-card, .queue-card, .activity-card { animation: card-in 260ms both ease-out; }
  .queue-card { animation-delay: 45ms; }
  .activity-card { animation-delay: 90ms; }
  @keyframes card-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
}

.login-body { min-height: 100vh; background: #eef1f2; }
.login-shell { display: grid; grid-template-columns: minmax(320px, 0.85fr) minmax(420px, 1.15fr); width: min(980px, calc(100% - 40px)); min-height: 610px; margin: clamp(28px, 7vh, 72px) auto; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 70px rgba(17, 27, 31, 0.12); }
.login-brand { display: flex; flex-direction: column; padding: 42px; color: #fff; background: var(--black); }
.login-brand-lockup { display: flex; gap: 12px; align-items: center; }
.login-brand-lockup img { width: 58px; height: 58px; object-fit: contain; }
.login-brand-lockup div { display: grid; text-transform: uppercase; }
.login-brand-lockup strong { font-size: 1.08rem; letter-spacing: 0.04em; }
.login-brand-lockup span { color: #b6bdc0; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; }
.login-brand-copy { margin: auto 0; }
.login-brand-copy .card-label { color: var(--blue); }
.login-brand-copy h1 { margin-top: 9px; font-size: clamp(2.7rem, 6vw, 4.6rem); line-height: 0.92; letter-spacing: -0.06em; }
.login-brand-copy p { max-width: 330px; margin-top: 22px; color: #aab0b2; font-size: 0.83rem; line-height: 1.6; }
.login-brand .brand-bars { margin: 0; }
.login-panel { display: grid; place-items: center; padding: 48px; }
.login-form { width: min(360px, 100%); }
.login-form header { margin-bottom: 32px; }
.login-form h2 { margin-top: 7px; font-size: 1.65rem; }
.login-form header p { margin: 8px 0 0; color: var(--muted); font-size: 0.78rem; }
.login-form label { display: block; margin: 18px 0 7px; color: #40484b; font-size: 0.7rem; font-weight: 750; }
.login-form input { width: 100%; min-height: 48px; padding: 0 13px; color: var(--black); background: var(--surface-soft); border: 1px solid #cfd5d8; border-radius: 8px; font: inherit; outline: none; transition: border-color 140ms ease, box-shadow 140ms ease; }
.login-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(28, 155, 215, 0.12); }
.login-submit { margin-top: 24px; }
.login-error { margin: 14px 0 -8px; color: var(--red); font-size: 0.73rem; }
.login-help { margin: 16px 0 0; color: var(--muted); font-size: 0.66rem; text-align: center; }
.microsoft-button { display: flex; justify-content: center; gap: 11px; align-items: center; min-height: 48px; margin-top: 22px; color: var(--black); background: #fff; border: 1px solid #cfd5d8; border-radius: 8px; font-size: 0.78rem; font-weight: 750; text-decoration: none; transition: background 140ms ease, border-color 140ms ease, transform 140ms ease; }
.microsoft-button:hover { background: var(--surface-soft); border-color: #aeb7bb; transform: translateY(-1px); }
.microsoft-button svg { width: 19px; height: 19px; }
.login-divider { display: flex; gap: 12px; align-items: center; margin: 22px 0 4px; color: var(--muted); font-size: 0.65rem; }
.login-divider::before, .login-divider::after { flex: 1; height: 1px; content: ""; background: var(--line); }

@media (max-width: 760px) {
  .login-shell { display: block; width: min(520px, calc(100% - 24px)); min-height: 0; margin: 12px auto; }
  .login-brand { min-height: 230px; padding: 26px; }
  .login-brand-copy { margin: 30px 0 22px; }
  .login-brand-copy h1 { font-size: 2.65rem; }
  .login-brand-copy p { display: none; }
  .login-panel { padding: 34px 26px 40px; }
}
