:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --ink: #171717;
  --muted: #667085;
  --line: #d8dee8;
  --nav: #111111;
  --blue: #334155;
  --green: #15803d;
  --teal: #0f766e;
  --orange: #f97316;
  --amber: #d97706;
  --red: #b42318;
  --violet: #7c3aed;
  --shadow: 0 8px 22px rgba(17, 17, 17, .07);
  font-family: Segoe UI, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #111 0%, #1f2937 58%, #f97316 160%);
}
.login-screen.show { display: flex; }
.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 26px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
}
.login-card strong { font-size: 24px; }
.login-card span { margin-top: -8px; color: var(--muted); }
.login-card p { min-height: 20px; margin: 0; color: var(--red); font-size: 13px; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: #111111;
  border-bottom: 3px solid var(--orange);
  color: #fff;
}

.app-header strong { display: block; font-size: 22px; }
.app-header span { display: block; margin-top: 3px; color: #d1d5db; font-size: 13px; }
.header-actions, .tabs, .toolbar, .lookup { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  cursor: pointer;
}

button:hover { filter: brightness(.98); }
.primary { background: var(--orange); color: #111; border-color: var(--orange); font-weight: 800; }
.ghost { background: #f8fafc; }
.danger { color: var(--red); border-color: #f3b7b4; }

.app-shell { max-width: 1440px; margin: 0 auto; padding: 18px 24px 42px; }
.tabs { margin-bottom: 18px; }
.tab { background: #edf2f7; border-color: transparent; color: #344054; }
.tab.active { background: var(--nav); color: #fff; border-color: var(--orange); }

.view { display: none; }
.view.active { display: block; }

.status-line {
  min-height: 34px;
  padding: 8px 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi { padding: 16px; min-height: 108px; border-left: 4px solid var(--orange); }
.kpi span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.kpi strong { display: block; margin-top: 12px; font-size: 26px; line-height: 1.1; }
.kpi.green { border-left-color: var(--green); }
.kpi.teal { border-left-color: var(--teal); }
.kpi.orange { border-left-color: var(--orange); }
.kpi.red { border-left-color: var(--red); }
.kpi.violet { border-left-color: var(--violet); }
.kpi.slate { border-left-color: #475569; }
.kpi.amber { border-left-color: var(--amber); }
.kpi.dark { border-left-color: #111; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.18fr .82fr;
  gap: 14px;
  align-items: start;
}

.panel { padding: 16px; overflow: hidden; }
.wide-panel { grid-column: 1 / -1; }
.panel.compact { max-width: 720px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel h2 { margin: 0; font-size: 17px; }
.panel p.helper {
  margin: 8px 0 0;
  color: #475467;
  font-size: 13px;
}
.compact-head { margin: 0 0 10px; }
.panel-total {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 8px;
  background: #111;
  color: #fff;
  border-left: 4px solid var(--orange);
  white-space: nowrap;
}
.panel-head h2::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 18px;
  margin-right: 8px;
  border-radius: 2px;
  background: var(--orange);
  vertical-align: -3px;
}
.muted { color: var(--muted); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}
.clean-form { gap: 14px 12px; }

label { display: grid; gap: 6px; color: #344054; font-size: 12px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
  color: var(--ink);
}

textarea { min-height: 78px; resize: vertical; }
.wide { grid-column: span 2; }
.full { grid-column: 1 / -1; }
.form-action {
  width: min(340px, 100%);
  justify-content: center;
  min-height: 40px;
}

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 1060px; background: #fff; }
th, td { padding: 10px 9px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; vertical-align: top; }
th { background: #f1f5f9; color: #344054; font-size: 12px; }
tr:hover td { background: #fafcff; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2f6;
  color: #344054;
}
.badge.red { background: #fee4e2; color: var(--red); }
.badge.yellow { background: #fef3c7; color: var(--orange); }
.badge.green { background: #dcfce7; color: var(--green); }
.badge.blue { background: #dbeafe; color: #1d4ed8; }
.badge.gray { background: #eaecf0; color: #475467; }
.badge.orange { background: #ffedd5; color: #c2410c; }
.badge.violet { background: #ede9fe; color: #6d28d9; }

.list { display: grid; gap: 10px; }
.list-item {
  display: grid;
  gap: 4px;
  padding: 11px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: #fff;
}
.list-item.red { border-left-color: var(--red); background: #fff8f7; }
.list-item.yellow { border-left-color: var(--orange); background: #fffbeb; }
.list-item.green { border-left-color: var(--green); background: #f0fdf4; }
.list-item small { color: var(--muted); }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(170px, .9fr) 110px 1.5fr; gap: 10px; align-items: center; }
.bar-track { height: 10px; background: #eef2f6; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; min-width: 2px; background: var(--orange); border-radius: 999px; }
.bar-fill.green { background: var(--green); }
.bar-fill.orange { background: var(--orange); }
.bar-fill.red { background: var(--red); }
.bar-fill.violet { background: var(--violet); }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button { min-height: 30px; padding: 5px 8px; font-size: 12px; }
.lookup { align-items: end; margin-bottom: 14px; }
.lookup label { min-width: 240px; }
.lookup-result { display: grid; gap: 8px; }
.lookup-card { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 14px; }
.lookup-card dl { display: grid; grid-template-columns: 180px 1fr; gap: 8px 12px; margin: 0; }
.lookup-card dt { color: var(--muted); font-weight: 700; }
.lookup-card dd { margin: 0; }

.supplier-grid { display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr)); gap: 12px; }
.supplier-card { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 14px; }
.supplier-card strong { display: block; margin-bottom: 8px; }
.hidden-block { display: none; }
.hidden-block.show { display: block; }
.supplier-values {
  margin: 0 0 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
}
.report-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}
.report-card h3 {
  margin: 0 0 12px;
  font-size: 15px;
}
.report-card ul {
  margin: 0;
  padding-left: 18px;
  line-height: 1.65;
  color: #344054;
}
.code-card { border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: #f8fafc; }
.config-list { display: grid; gap: 10px; }
.config-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.config-list span { color: var(--muted); }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #101828;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.empty { color: var(--muted); padding: 14px; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .dashboard-grid, .supplier-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
}

@media (max-width: 700px) {
  .app-header { align-items: flex-start; flex-direction: column; }
  .app-shell { padding: 14px; }
  .kpi-grid, .form-grid { grid-template-columns: 1fr; }
  .wide, .full { grid-column: auto; }
  .bar-row { grid-template-columns: 1fr; }
}
