:root {
  --ink: #17212b;
  --muted: #647487;
  --line: #d9e2ea;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --team: #0f766e;
  --factory: #7c3aed;
  --accent: #d97706;
  --danger: #b42318;
  --ok: #047857;
  --warn: #b45309;
  --shadow: 0 12px 30px rgba(24, 36, 50, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e0f2fe;
  color: #0f4f68;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.brand p {
  margin: 4px 0 0;
  color: #b8c5d1;
  font-size: 13px;
}

.role-panel {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 12px;
}

.role-panel label {
  display: block;
  color: #d9e5ef;
  font-size: 13px;
  margin-bottom: 8px;
}

.role-panel select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff;
  background: #233443;
  padding: 10px;
}

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

.nav button {
  background: transparent;
  color: #cbd7e2;
  text-align: right;
  border-radius: 8px;
  padding: 11px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav button.active,
.nav button:hover {
  background: #253848;
  color: #fff;
}

.nav .badge {
  min-width: 24px;
  height: 22px;
  border-radius: 999px;
  background: #f59e0b;
  color: #1f2937;
  font-size: 12px;
  display: grid;
  place-items: center;
  padding: 0 7px;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 20px;
}

.topbar h2 {
  margin: 0;
  font-size: 28px;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
}

.status-pill,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.status-pill {
  background: #e8f5f2;
  color: var(--team);
  border: 1px solid #b7ded5;
}

.pill {
  background: #eef2f6;
  color: #334155;
}

.pill.warn {
  background: #fff7ed;
  color: var(--warn);
}

.pill.ok {
  background: #ecfdf5;
  color: var(--ok);
}

.pill.danger {
  background: #fef3f2;
  color: var(--danger);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

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

.grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
  gap: 16px;
}

.full {
  grid-column: 1 / -1;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.field label {
  color: #334155;
  font-size: 13px;
  font-weight: 650;
}

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

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

.actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.btn {
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 40px;
  color: #fff;
  background: var(--team);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.btn.secondary {
  color: var(--ink);
  background: #e8edf2;
}

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

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

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

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 10px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: #475569;
  font-size: 13px;
  background: #f8fafc;
}

td {
  font-size: 14px;
}

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

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

.empty {
  color: var(--muted);
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  background: #fbfcfd;
}

.grade-row,
.allocation-row {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 10px;
  align-items: end;
  margin-bottom: 9px;
}

.allocation-row {
  grid-template-columns: 1.2fr 130px 90px;
}

.notice {
  border: 1px solid #fed7aa;
  background: #fff7ed;
  color: #9a3412;
  border-radius: 8px;
  padding: 11px 12px;
  margin: 12px 0;
}

.notification {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.counter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.counter-strip span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  padding: 8px 11px;
  font-size: 14px;
}

.counter-strip strong {
  color: var(--team);
  font-size: 18px;
}

.tab {
  background: #e8edf2;
  color: #334155;
  border-radius: 8px;
  min-height: 36px;
  padding: 8px 11px;
}

.tab.active {
  background: #14202c;
  color: #fff;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(90deg, rgba(20, 32, 44, 0.82), rgba(15, 118, 110, 0.62)),
    url("./assets/tilapia-login-bg.png");
  background-size: cover;
  background-position: center;
}

.login-card {
  width: min(460px, 100%);
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 25px;
}

.login-card p {
  margin: 0 0 18px;
  color: var(--muted);
}

.login-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}

.login-error {
  margin-top: 12px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

.lang-toggle {
  justify-content: center;
}

.login-card .lang-toggle {
  float: left;
  margin-bottom: 12px;
  color: var(--ink);
  background: #e8edf2;
  min-height: 36px;
  padding: 8px 12px;
}

html[dir="ltr"] .login-card .lang-toggle {
  float: right;
}

html[dir="ltr"] .nav button,
html[dir="ltr"] th,
html[dir="ltr"] td {
  text-align: left;
}

html[dir="ltr"] .brand,
html[dir="ltr"] .notification,
html[dir="ltr"] .topbar,
html[dir="ltr"] .actions,
html[dir="ltr"] .tabs,
html[dir="ltr"] .counter-strip {
  direction: ltr;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 660px) {
  .main {
    padding: 16px;
  }

  .topbar {
    display: block;
  }

  .nav,
  .metrics,
  .form-grid,
  .login-actions {
    grid-template-columns: 1fr;
  }

  .grade-row,
  .allocation-row {
    grid-template-columns: 1fr;
  }
}
