:root {
  --green: #14532d;
  --green2: #166534;
  --green3: #1e7040;
  --green-soft: #ecfdf3;
  --orange: #eb8f1d;
  --ink: #10231a;
  --muted: #66776d;
  --bg: #f3f7f4;
  --line: #dce7df;
  --panel: #ffffff;
  --red: #b42318;
  --red-soft: #fff1f0;
  --blue: #1d4ed8;
  --blue-soft: #eff6ff;
  --shadow: 0 18px 55px rgba(15, 38, 25, .15);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 15% 18%, rgba(235,143,29,.18), transparent 24rem),
    linear-gradient(145deg, #071b11, #14532d 65%, #1d6d3d);
}
.login-card {
  width: min(470px, 100%);
  padding: 31px;
  border-radius: 21px;
  background: white;
  box-shadow: 0 40px 100px rgba(0,0,0,.34);
}
.brand { display: flex; align-items: center; gap: 11px; }
.logo {
  width: 45px; height: 45px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: var(--orange);
  color: white;
  font-weight: 950;
}
.brand-name { font-size: 18px; font-weight: 950; }
.brand-sub { font-size: 11px; color: var(--muted); }
.login-copy { margin: 28px 0 19px; }
.login-copy h1 { margin: 5px 0 7px; font-size: 25px; }
.login-copy p { margin: 0; color: var(--muted); line-height: 1.5; }
.eyebrow {
  color: var(--orange);
  font-weight: 950;
  font-size: 10px;
  letter-spacing: .14em;
}
.form-stack { display: grid; gap: 15px; }
label {
  display: grid;
  gap: 6px;
  color: #344b3e;
  font-size: 12px;
  font-weight: 850;
}
input, select, textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid #c8d8ce;
  border-radius: 10px;
  background: white;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: #4f9368;
  box-shadow: 0 0 0 3px rgba(22,101,52,.10);
}
.local-box {
  display: grid;
  gap: 5px;
  margin-top: 18px;
  padding: 12px;
  border-radius: 11px;
  background: #f5f8f6;
  color: var(--muted);
  font-size: 11px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 268px;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  background: white;
  border-right: 1px solid var(--line);
}
.side-brand { padding: 0 3px; }
.company-identity {
  display: grid;
  gap: 3px;
  margin-top: 20px;
  padding: 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, #eefaf2, #f8fcf9);
  border: 1px solid #cce3d3;
}
.company-identity b { font-size: 13px; }
.company-identity span { color: var(--muted); font-size: 10px; }
.nav { display: grid; gap: 5px; margin-top: 18px; }
.nav-item {
  padding: 11px 13px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #42564b;
  text-align: left;
  font-weight: 850;
}
.nav-item:hover { background: #f1f6f2; }
.nav-item.active { background: var(--green); color: white; }
.account-box {
  display: grid;
  gap: 5px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.account-box b { font-size: 12px; }
.account-box > span { font-size: 10px; color: var(--muted); overflow-wrap: anywhere; }
.role-chip {
  width: fit-content;
  padding: 4px 7px;
  border-radius: 999px;
  background: #eaf1ff;
  color: var(--blue) !important;
  font-weight: 900;
}

.main { min-height: 100vh; margin-left: 268px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 22px;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.topbar h2 { margin: 0; font-size: 20px; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.top-actions, .section-toolbar, .modal-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.content { max-width: 1500px; margin: auto; padding: 20px; }
.view { display: none; }
.view.active { display: block; }

.btn {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  color: var(--ink);
  font-weight: 850;
}
.btn:hover { filter: brightness(.98); }
.btn:disabled { cursor: not-allowed; opacity: .55; }
.btn.primary { background: var(--green); color: white; border-color: var(--green); }
.btn.secondary { background: white; }
.btn.ghost { margin-top: 7px; background: #f6f9f7; }
.btn.full { width: 100%; }
.text-btn { border: 0; background: transparent; color: var(--green2); font-weight: 900; }
.icon-btn { border: 0; background: transparent; color: var(--muted); font-size: 25px; }

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
  border-radius: 17px;
  color: white;
  background: linear-gradient(135deg, #092316, #14532d 64%, #1f7141);
}
.hero h1 { margin: 6px 0; font-size: 25px; }
.hero p { margin: 0; color: #d4ecdc; }
.hero-code {
  padding: 11px 13px;
  border-radius: 11px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  font-weight: 900;
  white-space: nowrap;
}

.status-pill {
  padding: 7px 10px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 10px;
  white-space: nowrap;
}
.status-pill.good { background: #dcfce7; color: #166534; }
.status-pill.warning { background: #fff7ed; color: #9a3412; }
.status-pill.bad { background: #fee2e2; color: #991b1b; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 13px;
  margin-top: 14px;
}
.stat-card {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}
.stat-card span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.stat-card strong { display: block; margin: 6px 0 3px; font-size: 29px; }
.stat-card small { color: var(--muted); }
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
  margin-top: 13px;
}
.panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}
.panel h3 { margin: 0 0 12px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.recent-audit-panel { margin-top: 13px; }
.list-item {
  display: flex;
  justify-content: space-between;
  gap: 13px;
  padding: 10px 0;
  border-bottom: 1px solid #edf2ef;
}
.list-item:last-child { border-bottom: 0; }
.list-main b { display: block; font-size: 12px; }
.list-main small, .list-side small { color: var(--muted); }
.list-side { text-align: right; }

.capacity-list { display: grid; gap: 14px; }
.capacity-list > div { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; }
.capacity-list span { font-size: 11px; color: var(--muted); }
.capacity-list b { font-size: 11px; }
.bar {
  grid-column: 1 / -1;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7efe9;
}
.bar i { display: block; width: 0; height: 100%; background: var(--green3); transition: width .25s; }
.bar.neutral i { width: 100%; background: #b8c8be; }

.section-toolbar { justify-content: space-between; margin-bottom: 12px; }
.search { max-width: 430px; }
.table-card {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
}
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th {
  padding: 10px;
  background: #f7faf8;
  color: var(--muted);
  font-size: 9px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
td { padding: 10px; border-top: 1px solid #edf2ef; vertical-align: middle; }
td b { display: block; }
td small { color: var(--muted); }
.row-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.mini-btn {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  font-size: 10px;
  font-weight: 850;
}
.mini-btn.danger { color: var(--red); border-color: #efbbb5; }
.badge {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 900;
  white-space: nowrap;
}
.badge.active, .badge.accepted { color: #166534; background: #dcfce7; }
.badge.invited, .badge.pending { color: #9a3412; background: #fff7ed; }
.badge.suspended, .badge.cancelled, .badge.expired { color: #991b1b; background: #fee2e2; }
.badge.role { color: var(--blue); background: #eaf1ff; }
.badge.neutral { color: #475569; background: #f1f5f9; }

.info-banner {
  margin-bottom: 12px;
  padding: 11px 13px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: var(--blue-soft);
  color: #1e40af;
  font-size: 12px;
}
.info-banner a { color: inherit; font-weight: 900; }
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}
.profile-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}
.profile-card h3 { margin: 0 0 12px; }
.kv {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  padding: 8px 0;
  border-bottom: 1px solid #edf2ef;
  font-size: 12px;
}
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { max-width: 65%; font-weight: 800; text-align: right; overflow-wrap: anywhere; }

.system-panel { margin-top: 13px; }
.command-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.command-grid > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.command-grid b, .command-grid code { display: block; }
.command-grid code { margin-top: 7px; color: var(--green2); overflow-wrap: anywhere; }
.safe-note {
  margin-top: 13px;
  padding: 11px;
  border: 1px solid #b7e1c1;
  border-radius: 10px;
  background: var(--green-soft);
  color: var(--green2);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4,17,10,.72);
}
.modal {
  width: min(800px, 100%);
  max-height: 92vh;
  overflow: auto;
  border-radius: 16px;
  background: white;
  box-shadow: var(--shadow);
}
.modal.small { width: min(570px, 100%); }
.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 15px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: white;
}
.modal-head h3 { margin: 0; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.modal-body { padding: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: 1 / -1; }
.checkbox-row {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
}
.checkbox-row input { width: auto; }
.modal-actions { justify-content: flex-end; margin-top: 18px; }
.role-guide {
  display: grid;
  gap: 5px;
  margin-top: 15px;
  padding: 12px;
  border-radius: 10px;
  background: #f5f8f6;
  color: var(--muted);
  font-size: 11px;
}
.role-guide b { color: var(--ink); }
.success-box {
  padding: 14px;
  border: 1px solid #b7e1c1;
  border-radius: 11px;
  background: var(--green-soft);
}
.success-box code {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
}
.message {
  margin-top: 12px;
  padding: 10px;
  border-radius: 9px;
  font-size: 11px;
}
.message.error {
  border: 1px solid #efbbb5;
  background: var(--red-soft);
  color: var(--red);
}
.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  max-width: 410px;
  padding: 11px 14px;
  border-radius: 10px;
  background: #1f2937;
  color: white;
  box-shadow: var(--shadow);
  transform: translateY(-130px);
  opacity: 0;
  transition: .2s;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--red); }

@media (max-width: 1080px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { position: static; width: 100%; }
  .company-identity, .account-box { display: none; }
  .nav { grid-template-columns: repeat(3, 1fr); }
  .main { margin-left: 0; }
  .topbar, .hero { align-items: flex-start; flex-direction: column; }
  .form-grid, .profile-grid, .command-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
