:root {
  color-scheme: dark;
  --bg: #0a0a0f;
  --bg-soft: #0f0f12;
  --panel: #171515;
  --panel-raised: #1a1a1c;
  --stage: #12121a;
  --line: rgba(232, 213, 163, 0.16);
  --line-strong: rgba(232, 213, 163, 0.34);
  --text: #f6f6f6;
  --muted: #a3a3a5;
  --muted-strong: #d2d0ca;
  --accent: #997d58;
  --accent-strong: #d4b86a;
  --accent-hot: #e5a910;
  --accent-soft: rgba(153, 125, 88, 0.14);
  --danger: #f97066;
  --shadow: 0 18px 44px rgba(0, 0, 2, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

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

button,
.file-button {
  border: 1px solid rgba(229, 169, 16, 0.34);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  font-weight: 650;
  box-shadow: 0 8px 20px rgba(153, 125, 88, 0.18);
}

button:hover,
.file-button:hover {
  background: var(--accent-strong);
  color: #0a0a0f;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0a0a0d;
  color: var(--text);
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(212, 184, 106, 0.16);
  outline: none;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  padding: 28px;
}

.login-logo {
  display: block;
  width: 76px;
  height: 76px;
  object-fit: contain;
  margin-bottom: 14px;
}

.login-panel h1,
.topbar h1 {
  margin: 0;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.form-error {
  min-height: 20px;
  color: var(--danger);
  margin: 0;
}

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

.sidebar {
  background: #000002;
  color: #fff;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 6px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: #0a0a0d;
  border: 1px solid var(--line-strong);
  font-weight: 800;
  overflow: hidden;
}

.brand-mark img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.brand small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

nav {
  display: grid;
  gap: 6px;
}

.nav-item,
.ghost-button,
.icon-button {
  background: transparent;
  color: inherit;
  border: 1px solid transparent;
}

.nav-item {
  justify-content: flex-start;
  color: #d2d0ca;
  box-shadow: none;
}

.nav-item.active,
.nav-item:hover {
  background: var(--accent-soft);
  border-color: var(--line-strong);
  color: #fff;
}

.ghost-button {
  margin-top: auto;
  border-color: var(--line);
  color: var(--text);
}

.sidebar .ghost-button {
  color: #d2d0ca;
  border-color: var(--line);
  box-shadow: none;
}

.workspace {
  min-width: 0;
  padding: 24px;
  background: var(--bg);
}

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

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.stat {
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: 7px;
  min-width: 96px;
  padding: 8px 10px;
}

.stat strong {
  display: block;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar input,
.toolbar select {
  width: min(300px, 100%);
}

.file-button input {
  display: none;
}

.pipeline-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(250px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.stage {
  background: var(--stage);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 560px;
  padding: 10px;
}

.stage-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 8px;
  margin-bottom: 10px;
}

.stage-head h3 {
  font-size: 14px;
  margin: 0;
  color: var(--text);
}

.stage-head span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.opportunity-card,
.record-card,
.table-card,
.course-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 2, 0.18);
}

.opportunity-card {
  padding: 11px;
  margin-bottom: 9px;
  cursor: grab;
  border-left: 3px solid var(--accent);
}

.opportunity-card:active {
  cursor: grabbing;
}

.opportunity-card strong {
  display: block;
  margin-bottom: 4px;
  color: #fff;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.table-card {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

th {
  color: var(--accent-strong);
  font-size: 12px;
  text-transform: uppercase;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.row-actions button {
  min-height: 30px;
  padding: 0 10px;
}

.course-grid,
.split-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.course-card,
.record-card {
  padding: 14px;
}

.course-card h3,
.record-card h3 {
  margin: 0 0 8px;
}

dialog {
  width: min(720px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
  background: var(--panel);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 2, 0.72);
}

#modalForm {
  padding: 18px;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 {
  margin: 0;
}

.icon-button {
  color: var(--text);
  min-width: 34px;
  padding: 0;
  font-size: 22px;
}

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

.modal-fields label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

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

.modal-actions {
  justify-content: flex-end;
}

.modal-actions .ghost-button {
  margin: 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  border-radius: 7px;
  background: #000002;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line-strong);
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: block;
  }

  .brand {
    margin-bottom: 12px;
  }

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

  .sidebar .ghost-button {
    margin-top: 12px;
    width: 100%;
  }

  .workspace {
    padding: 16px;
  }

  .topbar {
    display: block;
  }

  .summary {
    justify-content: flex-start;
    margin-top: 12px;
  }

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