:root {
  --bg: #0b0c0c;
  --panel: #121413;
  --panel-2: #171a18;
  --panel-3: #1f231f;
  --line: #2b302c;
  --line-strong: #3c443e;
  --text: #f0f2ed;
  --muted: #9aa29a;
  --faint: #697169;
  --accent: #d8b35a;
  --accent-soft: rgba(216, 179, 90, 0.12);
  --green: #5fc88f;
  --green-soft: rgba(95, 200, 143, 0.12);
  --red: #e05757;
  --red-soft: rgba(224, 87, 87, 0.12);
  --amber: #d89d4c;
  --amber-soft: rgba(216, 157, 76, 0.13);
  --radius: 6px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(180deg, #101211 0%, #090a0a 100%);
  color: var(--text);
  font-family: Aptos, "Segoe UI Variable", "Helvetica Neue", sans-serif;
  letter-spacing: 0;
}

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

button {
  color: inherit;
}

#app {
  min-height: 100vh;
}

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

.side-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: rgba(13, 15, 14, 0.96);
  border-right: 1px solid var(--line);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark,
.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-weight: 800;
}

.brand-lockup strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.brand-lockup span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

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

.nav-item {
  display: grid;
  gap: 3px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  padding: 12px 13px;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.nav-item span {
  font-size: 14px;
  font-weight: 700;
}

.nav-item small {
  color: var(--faint);
  font-size: 11px;
}

.nav-item:hover {
  background: var(--panel);
  border-color: var(--line);
}

.nav-item.active {
  background: var(--panel-2);
  border-color: var(--accent);
  color: #fff;
}

.nav-item.active small {
  color: var(--accent);
}

.logout-btn {
  margin-top: auto;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 11px 13px;
  cursor: pointer;
}

.logout-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

.workspace {
  min-width: 0;
  padding: 26px 30px 40px;
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 22px;
  margin-bottom: 22px;
  background: rgba(18, 20, 19, 0.82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.workspace-header h1 {
  font-size: 30px;
  line-height: 1.05;
  margin: 4px 0 6px;
  font-weight: 800;
}

.workspace-header span,
.eyebrow {
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  color: var(--accent);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
}

.login-container {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: rgba(18, 20, 19, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 34px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

.login-card .mark {
  margin-bottom: 22px;
}

.login-card h1 {
  font-size: 28px;
  margin-bottom: 6px;
}

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

.form-error {
  color: var(--red) !important;
  background: var(--red-soft);
  border: 1px solid rgba(224, 87, 87, 0.25);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
}

input,
select,
textarea,
.search-input,
.filter-select,
.note-input {
  background: #0d0f0e;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
}

.login-card input,
.search-input,
.filter-select {
  min-height: 40px;
  padding: 10px 12px;
  font-size: 13px;
}

.login-card input {
  width: 100%;
  margin-bottom: 12px;
}

input:focus,
select:focus,
textarea:focus,
.search-input:focus,
.filter-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-card .label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 800;
  margin-bottom: 9px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 850;
  line-height: 1;
}

.green { color: var(--green); }
.red { color: var(--red); }
.amber { color: var(--amber); }
.accent { color: var(--accent); }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 10px;
}

.section-heading h3 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--text);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
  min-width: 220px;
}

.table-container {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 11px 13px;
  background: var(--panel-3);
  color: var(--muted);
  border-bottom: 1px solid var(--line-strong);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 850;
  white-space: nowrap;
}

td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  color: #d7dbd4;
  font-size: 13px;
  white-space: nowrap;
}

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

tbody tr:hover {
  background: rgba(216, 179, 90, 0.055);
}

.code {
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  color: var(--accent);
  font-size: 12px;
}

.metric-cell {
  display: inline-grid;
  gap: 2px;
  min-width: 42px;
}

.metric-cell strong {
  font-size: 13px;
  color: var(--text);
}

.metric-cell small {
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--faint);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
}

.badge-license {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.badge-regular,
.badge-active {
  color: var(--green);
  background: var(--green-soft);
}

.badge-extended {
  color: var(--accent);
  background: var(--accent-soft);
}

.badge-blocked {
  color: var(--red);
  background: var(--red-soft);
}

.badge-amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.btn {
  min-height: 34px;
  padding: 8px 13px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: #17130a;
}

.btn-danger {
  background: transparent;
  border-color: rgba(224, 87, 87, 0.5);
  color: var(--red);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--text);
}

.btn-sm {
  min-height: 28px;
  padding: 5px 9px;
  font-size: 12px;
}

.btn-wide {
  width: 100%;
  min-height: 42px;
}

.actions-cell {
  display: flex;
  gap: 5px;
}

.drawer-overlay,
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.64);
  animation: fadeIn 0.16s ease;
}

.drawer-overlay {
  display: flex;
  justify-content: flex-end;
}

.drawer {
  width: 620px;
  max-width: 94vw;
  height: 100vh;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--line-strong);
  animation: slideIn 0.2s ease;
}

.drawer-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  background: rgba(18, 20, 19, 0.96);
  border-bottom: 1px solid var(--line);
}

.drawer-body {
  padding: 18px 22px 26px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.summary-pill,
.note-panel,
.event-item,
.modal-card {
  background: #0f1110;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.summary-pill {
  padding: 10px;
}

.summary-pill span,
.detail-label,
.note-panel label,
.event-meta,
.event-top span,
.empty-small {
  color: var(--muted);
  font-size: 12px;
}

.summary-pill strong {
  display: block;
  font-size: 20px;
  margin-top: 4px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.detail-value {
  text-align: right;
  word-break: break-all;
  font-size: 13px;
}

.drawer-section-title {
  margin: 22px 0 10px;
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
}

.note-panel {
  display: grid;
  gap: 9px;
  padding: 12px;
}

.note-input {
  width: 100%;
  padding: 10px;
  resize: vertical;
}

.policy-note {
  margin-top: 12px;
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid rgba(216, 157, 76, 0.24);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
}

.event-list {
  display: grid;
  gap: 8px;
}

.event-item {
  border-left: 3px solid var(--muted);
  padding: 10px;
}

.event-item.accepted { border-left-color: var(--green); }
.event-item.rejected { border-left-color: var(--amber); }
.event-item.blocked { border-left-color: var(--red); }

.event-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 12px;
}

.event-error {
  margin-top: 6px;
  color: var(--red);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 200;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success { background: var(--green); color: #07120b; }
.toast-error { background: var(--red); color: white; }
.toast-info { background: var(--accent); color: #17130a; }

.modal-overlay {
  display: grid;
  place-items: center;
}

.modal-card {
  width: min(420px, 92vw);
  padding: 20px;
}

.empty,
.loading {
  padding: 46px;
  color: var(--muted);
  text-align: center;
}

.empty .icon {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

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

  .side-panel {
    position: static;
    height: auto;
  }

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

  .workspace {
    padding: 18px;
  }

  .workspace-header {
    flex-direction: column;
  }
}
