:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-2: #eef3f6;
  --text: #17202a;
  --muted: #637083;
  --line: #d9e1e8;
  --primary: #16324f;
  --primary-press: #0f253d;
  --accent: #2f9f7b;
  --warning: #b7791f;
  --danger: #bb3e45;
  --info: #2d6cdf;
  --shadow: 0 14px 35px rgba(22, 50, 79, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

a {
  color: var(--primary);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(320px, 1.05fr);
}

.login-brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(22, 50, 79, 0.96), rgba(28, 72, 102, 0.96)),
    url("/portal-mark.svg") center 55% / 260px 260px no-repeat;
}

.brand-row,
.top-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-row img,
.top-brand img {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}

.brand-row strong,
.top-brand strong {
  font-size: 19px;
  line-height: 1.2;
}

.login-brand h1 {
  margin: 0;
  max-width: 540px;
  font-size: 40px;
  line-height: 1.08;
  font-weight: 760;
}

.login-brand p {
  margin: 18px 0 0;
  max-width: 520px;
  color: #d9e6ef;
  line-height: 1.55;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px;
}

.login-card {
  width: min(100%, 430px);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card h2,
.section-title h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.login-card p,
.section-title p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.login-fields {
  margin-top: 20px;
}

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

.field label {
  color: #384657;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: #ffffff;
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 3px solid rgba(47, 159, 123, 0.18);
  border-color: var(--accent);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 9px 13px;
  color: #ffffff;
  background: var(--primary);
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--primary-press);
}

.btn.secondary {
  color: var(--primary);
  border: 1px solid var(--line);
  background: #ffffff;
}

.btn.secondary:hover {
  border-color: #b7c4cf;
  background: #f6f9fb;
}

.btn.success {
  background: var(--accent);
}

.btn.success:hover {
  background: #278a6b;
}

.btn.danger {
  background: var(--danger);
}

.btn.danger:hover {
  background: #9d3138;
}

.btn.small {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

.message {
  min-height: 20px;
  color: var(--muted);
  line-height: 1.4;
}

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

.message.success {
  color: #126245;
}

.message.info {
  color: var(--info);
}

.link-button {
  width: fit-content;
  padding: 0;
  color: var(--primary);
  background: transparent;
  font-weight: 750;
  text-align: left;
}

.link-button:hover {
  text-decoration: underline;
}

.setup-box {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.setup-box code {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--primary);
  background: #ffffff;
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.demo-logins {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.user-meta span {
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: calc(100vh - 68px);
}

.sidebar {
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.nav-button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  border-radius: 8px;
  padding: 9px 11px;
  color: #304153;
  background: transparent;
  font-weight: 720;
}

.nav-button:hover,
.nav-button.active {
  color: var(--primary);
  background: var(--panel-2);
}

.main {
  min-width: 0;
  padding: 26px;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

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

.stat {
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  color: #34495e;
  background: #ffffff;
  font-weight: 720;
}

.chip.active {
  color: #ffffff;
  border-color: var(--primary);
  background: var(--primary);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.panel.pad {
  padding: 18px;
}

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

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #405064;
  background: #f8fafc;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
}

tr:last-child td {
  border-bottom: 0;
}

.doc-main {
  display: grid;
  gap: 4px;
}

.doc-main strong {
  word-break: break-word;
}

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

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}

.status.pending {
  color: #7a4d09;
  background: #fff3d6;
}

.status.approved {
  color: #126245;
  background: #dff6ec;
}

.status.rejected {
  color: #8b242b;
  background: #ffe2e4;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 230px;
}

.empty-state {
  padding: 40px 18px;
  color: var(--muted);
  text-align: center;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(300px, 0.78fr) minmax(0, 1.22fr);
  gap: 18px;
}

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

.supplier-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.supplier-item strong,
.supplier-item span {
  overflow-wrap: anywhere;
}

.file-input {
  padding: 9px 10px;
}

@media (max-width: 980px) {
  .login-shell,
  .layout,
  .two-column {
    grid-template-columns: 1fr;
  }

  .login-brand {
    min-height: 300px;
    padding: 30px;
  }

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

  .sidebar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-button {
    width: auto;
    flex: 0 0 auto;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(145px, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar,
  .section-header,
  .toolbar,
  .user-meta {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: static;
    padding: 14px;
  }

  .main,
  .login-panel,
  .login-brand {
    padding: 18px;
  }

  .login-card {
    padding: 20px;
  }

  .demo-logins,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .button-row,
  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn,
  .chip {
    width: 100%;
  }
}
