:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --ink: #1f2937;
  --muted: #667085;
  --line: #d8e0ea;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --accent: #c2410c;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --shadow: 0 14px 45px rgba(31, 41, 55, .12);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(115deg, rgba(15, 118, 110, .94), rgba(30, 64, 175, .86)),
    url("https://images.unsplash.com/photo-1556761175-b413da4baf72?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.login-panel {
  width: min(430px, 100%);
  padding: 34px;
  border-radius: 8px;
  color: #fff;
  background: rgba(10, 24, 38, .84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.brand-mark {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  font-size: .82rem;
}

.login-panel h1 {
  margin: 20px 0 8px;
  font-size: 2rem;
}

.login-panel p {
  margin: 0 0 24px;
  color: rgba(255, 255, 255, .78);
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 700;
}

.login-panel label {
  color: rgba(255, 255, 255, .86);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .14);
}

.primary-btn,
.ghost-btn,
.icon-btn {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-btn {
  color: #fff;
  background: var(--brand);
}

.primary-btn:hover {
  background: var(--brand-dark);
}

.ghost-btn {
  color: var(--ink);
  background: var(--surface-2);
}

.ghost-btn.full {
  width: 100%;
}

.icon-btn {
  width: 40px;
  min-height: 40px;
  padding: 0;
  color: var(--muted);
  background: var(--surface-2);
}

.form-error {
  min-height: 20px;
  color: #fecaca;
  font-weight: 700;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
  border-right: 1px solid var(--line);
  background: #101827;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
}

.sidebar-brand span {
  display: block;
  margin-top: 3px;
  color: #aeb9c7;
  font-size: .82rem;
}

.module-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  text-align: left;
  color: #d4dbe7;
  background: transparent;
  font-weight: 750;
}

.nav-item:hover,
.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, .1);
}

.workspace {
  min-width: 0;
  padding: 28px;
}

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

.topbar h2 {
  margin: 4px 0 0;
  font-size: 1.7rem;
}

.eyebrow {
  color: var(--brand);
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-input {
  width: min(360px, 40vw);
}

.module {
  display: none;
}

.module.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric,
.panel,
.record,
.kanban-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 25px rgba(31, 41, 55, .05);
}

.metric {
  padding: 20px;
}

.metric span {
  color: var(--muted);
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 1.9rem;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.panel {
  padding: 18px;
}

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

.section-heading h3 {
  margin: 0;
  font-size: 1.15rem;
}

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

.record {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.record header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.record h4 {
  margin: 0;
  font-size: 1rem;
}

.record p {
  margin: 0;
  color: var(--muted);
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-btn {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  font-weight: 800;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  color: var(--brand-dark);
  background: rgba(15, 118, 110, .12);
  font-size: .78rem;
  font-weight: 900;
}

.pill.warn {
  color: var(--warning);
  background: rgba(180, 83, 9, .13);
}

.pill.danger {
  color: var(--danger);
  background: rgba(185, 28, 28, .12);
}

.list-stack {
  display: grid;
  gap: 10px;
}

.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(210px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-column {
  min-height: 420px;
  padding: 14px;
}

.kanban-column h4 {
  margin: 0 0 12px;
}

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

.form-grid .wide,
.form-grid button,
.preview-box {
  grid-column: 1 / -1;
}

.preview-box {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-2);
  white-space: pre-wrap;
}

dialog {
  width: min(760px, calc(100vw - 30px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(16, 24, 39, .48);
}

.dialog-card {
  display: grid;
  gap: 18px;
  padding: 22px;
  background: #fff;
}

.dialog-card header,
.dialog-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-card h3 {
  margin: 0;
}

.dialog-card footer {
  justify-content: flex-end;
}

.detail-card dl {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px 16px;
  margin: 0;
}

.detail-card dt {
  color: var(--muted);
  font-weight: 900;
}

.detail-card dd {
  margin: 0;
}

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

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

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

  .topbar,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search-input {
    width: 100%;
  }

  .metric-grid,
  .two-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .module-nav,
  .metric-grid,
  .two-column,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .detail-card dl {
    grid-template-columns: 1fr;
  }
}
