:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #5f6b7a;
  --line: #d9e1ea;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-soft: #e6f5f3;
  --danger: #a23333;
  --gold: #c79a32;
  --shadow: 0 10px 30px rgba(20, 32, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

a {
  color: var(--primary);
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 12px clamp(16px, 3vw, 32px);
  background: #13202e;
  color: #fff;
  box-shadow: 0 8px 28px rgba(10, 20, 30, 0.18);
}

.brand {
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  min-width: 0;
}

.brand span:last-child {
  overflow-wrap: anywhere;
}

.brand-mark {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--gold);
  color: #13202e;
  font-size: 13px;
  letter-spacing: 0;
}

.topbar nav,
.topbar form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar a,
.topbar span {
  color: #eef2f7;
  font-size: 14px;
}

.topbar nav {
  justify-content: center;
}

.topbar nav a,
.nav-button {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 9px 13px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-weight: 700;
  line-height: 1;
}

.topbar nav a:hover {
  background: #fff;
  color: #13202e;
}

.shell {
  width: min(1200px, calc(100% - 28px));
  margin: clamp(16px, 3vw, 30px) auto;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-heading p {
  margin: 0;
}

h1,
h2 {
  margin: 0 0 10px;
}

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

.panel,
.widget {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(16px, 2vw, 24px);
  box-shadow: var(--shadow);
}

.auth-panel {
  max-width: 460px;
  margin: 60px auto;
}

.auth-switch {
  margin: 14px 0 0;
  text-align: center;
}

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

.form-grid.multi {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
}

label,
legend {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  font: inherit;
  background: #fff;
}

select[multiple] {
  min-height: 118px;
  padding: 8px;
}

.choice-list {
  display: grid;
  gap: 8px;
  max-height: 150px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}

.choice-list.compact {
  max-height: 126px;
}

.choice-list .check-row {
  font-size: 13px;
  overflow-wrap: anywhere;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
  outline: none;
}

textarea {
  min-height: 220px;
  font-family: Consolas, "Courier New", monospace;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 500;
}

.check-row input {
  width: auto;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  text-align: center;
}

button:hover,
.button:hover {
  background: var(--primary-dark);
  color: #fff;
}

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  background: #f8fafc;
}

small {
  display: block;
  color: var(--muted);
}

.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 13px;
  font-weight: 700;
  text-transform: capitalize;
}

.status.pending {
  background: #fff4d8;
  color: #875a00;
}

.status.approved {
  background: #dff7ea;
  color: #14633a;
}

.status.rejected {
  background: #fde0e0;
  color: #842222;
}

.inline-actions,
.inline-edit {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-edit {
  display: grid;
  grid-template-columns: minmax(120px, 150px) minmax(130px, 150px) minmax(220px, 1fr) auto;
  align-items: start;
  width: 100%;
}

.flash {
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 12px 14px;
  font-weight: 700;
}

.flash.success {
  background: #dff7ea;
  color: #14633a;
}

.flash.error {
  background: #fde0e0;
  color: #842222;
}

.widgets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.plain-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

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

.inline-stats {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 6px;
}

.metric-card {
  display: grid;
  gap: 6px;
  min-height: 132px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfd;
}

.metric-value {
  color: var(--ink);
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}

.metric-label {
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

.metric-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.balance-panel {
  margin-bottom: 18px;
}

.balance-note {
  margin-top: -4px;
}

.stats span {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.person-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.custom-widget p {
  margin-bottom: 0;
}

.kpi-widget strong {
  display: block;
  color: var(--primary-dark);
  font-size: 34px;
  line-height: 1.1;
  margin: 6px 0;
}

.mini-stats {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.mini-stats span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 7px;
}

.mini-stats strong {
  color: var(--ink);
}

.empty {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar nav,
  .topbar form {
    justify-content: flex-start;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-grid.multi,
  .inline-edit {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 20px, 1200px);
  }

  .topbar {
    padding: 12px;
  }

  .topbar nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .brand {
    align-items: flex-start;
  }

  .topbar nav a,
  .topbar form button {
    justify-content: center;
    text-align: center;
  }

  .topbar form {
    width: 100%;
  }

  .topbar form span {
    overflow-wrap: anywhere;
  }

  .auth-panel {
    margin: 22px auto;
  }

  .table-wrap {
    border: 0;
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 12px;
    background: #fff;
    box-shadow: var(--shadow);
    overflow: hidden;
  }

  td {
    display: grid;
    grid-template-columns: minmax(96px, 38%) 1fr;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding: 12px;
  }

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

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
  }

  td.empty {
    display: block;
  }

  td.empty::before {
    content: "";
  }

  .inline-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
