:root {
  --bg: #f6f2ed;
  --panel: #fffdf9;
  --ink: #1f1b16;
  --muted: #756b60;
  --line: #e3d8cc;
  --brand: #2f6d4f;
  --brand-dark: #194a35;
  --accent: #c45a31;
  --gold: #d99a35;
  --danger: #b42318;
  --shadow: 0 14px 34px rgba(48, 34, 22, 0.13);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--brand-dark);
}

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

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

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

.hero {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
}

.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(36, 21, 11, 0.7), rgba(36, 21, 11, 0.04));
}

.hero-copy {
  position: absolute;
  left: clamp(26px, 6vw, 84px);
  bottom: clamp(34px, 8vh, 88px);
  z-index: 1;
  max-width: 720px;
  color: #fff;
}

.hero-copy h1 {
  margin: 12px 0;
  font-size: clamp(38px, 5vw, 66px);
  line-height: 1.04;
}

.hero-copy p,
.hero-copy span {
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  background: var(--panel);
  padding: 48px;
}

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

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

.brand strong {
  display: block;
  font-size: 22px;
}

.brand span,
.topbar p,
.panel-toolbar p {
  color: var(--muted);
}

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

.login-form label {
  display: grid;
  gap: 7px;
  color: #4f463e;
}

#loginMessage {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
}

.demo-accounts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.demo-accounts button,
.top-actions button,
.toolbar-actions button,
.row-actions button,
dialog footer button:first-child {
  background: #efe8df;
  color: #2d251f;
}

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

.sidebar {
  background: #2f261e;
  color: #fff;
}

.brand.compact {
  padding: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand.compact span {
  color: rgba(255, 255, 255, 0.72);
}

#moduleNav {
  display: grid;
  gap: 4px;
  padding: 12px;
}

#moduleNav button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  min-height: 42px;
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  text-align: left;
}

#moduleNav button.active,
#moduleNav button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

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

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

.topbar p,
.topbar h2,
.panel-toolbar h3,
.panel-toolbar p {
  margin: 0;
}

.topbar h2 {
  margin-top: 4px;
  font-size: 30px;
}

.top-actions,
.toolbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.dashboard {
  display: grid;
  gap: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.stat-card,
.activity-panel,
.chart-panel,
.module-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 16px;
}

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

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 18px;
}

.activity-panel,
.chart-panel {
  padding: 18px;
}

.activity-item {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.activity-item:first-of-type {
  border-top: 0;
}

.activity-item strong {
  display: block;
}

.activity-item p {
  margin: 6px 0 0;
  color: var(--muted);
}

.bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 54px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #eadfd3;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
}

.module-panel {
  overflow: hidden;
}

.panel-toolbar {
  padding: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
}

.toolbar-actions input {
  width: 240px;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  background: #faf5ee;
  color: #4f463e;
}

.truncate {
  display: inline-block;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: #eaf7f0;
  color: var(--brand);
  font-size: 12px;
}

.badge.warn {
  background: #fff1e8;
  color: var(--accent);
}

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

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

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

dialog::backdrop {
  background: rgba(25, 18, 12, 0.48);
}

dialog header,
dialog footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

dialog footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

dialog h3 {
  margin: 0;
}

#closeDialogButton {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  background: #efe8df;
  color: #2d251f;
  font-size: 22px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.form-grid label {
  display: grid;
  gap: 7px;
  color: #4f463e;
}

.form-grid label.wide {
  grid-column: 1 / -1;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 40px));
  border-radius: 8px;
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

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

  .hero {
    min-height: 36vh;
  }

  #moduleNav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

@media (max-width: 640px) {
  .login-panel,
  .workspace {
    padding: 16px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .brand.compact {
    padding: 12px 16px;
  }

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

  .topbar h2 {
    font-size: 26px;
  }

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

  .toolbar-actions input,
  .toolbar-actions button,
  .top-actions button {
    width: 100%;
  }

  #moduleNav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 12px 12px;
  }

  #moduleNav button {
    display: inline-flex;
    flex: 0 0 auto;
    justify-content: center;
    width: auto;
    min-width: 104px;
    min-height: 36px;
    padding: 0 12px;
    color: #fff;
    white-space: nowrap;
  }

  #moduleNav button small {
    display: none;
  }

  .demo-accounts,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .hero-copy h1 {
    font-size: 34px;
  }
}
