:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #182032;
  --muted: #667085;
  --line: #dde3ed;
  --primary: #0d7f74;
  --primary-strong: #075d55;
  --accent: #c47a1b;
  --danger: #bd2c3a;
  --good: #248a4b;
  --shadow: 0 18px 45px rgba(38, 55, 80, 0.12);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body.authenticated .login-screen {
  display: none !important;
}

body:not(.authenticated) .app {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(13, 127, 116, 0.12), transparent 24rem),
    linear-gradient(135deg, #f8fafc 0%, #eef3f7 50%, #f6f0e8 100%);
}

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

button {
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(20rem, 1fr) minmax(20rem, 28rem);
  align-items: center;
  gap: 4rem;
  padding: 5vw;
}

.login-story {
  max-width: 38rem;
}

.mark {
  display: inline-grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  border-radius: 1rem;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #1f9ab0 56%, var(--accent));
  font-weight: 900;
  letter-spacing: 0;
}

.mark.small {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  font-size: 0.9rem;
}

.overline {
  margin: 0 0 0.5rem;
  color: var(--primary-strong);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

.login-story h1 {
  margin: 1.5rem 0 1rem;
  font-size: clamp(2.4rem, 6vw, 5rem);
  line-height: 1.02;
}

.login-story p:last-child {
  color: #475467;
  font-size: 1.1rem;
  line-height: 1.8;
}

.login-card,
.panel,
dialog {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow);
}

.login-card {
  border-radius: 1.25rem;
  padding: 2rem;
}

label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

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

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 127, 116, 0.14);
}

.login-card label + label {
  margin-top: 1rem;
}

.primary,
.ghost,
.icon {
  border: 0;
  border-radius: 0.7rem;
  min-height: 2.6rem;
  padding: 0 1rem;
  font-weight: 800;
}

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

.primary:hover {
  background: var(--primary-strong);
}

.ghost {
  color: var(--ink);
  background: #edf2f7;
}

.icon {
  width: 2.4rem;
  padding: 0;
  color: var(--muted);
  background: #eef2f6;
}

.error {
  min-height: 1.25rem;
  color: var(--danger);
  font-weight: 700;
}

.login-card .primary {
  width: 100%;
  margin-top: 0.5rem;
}

.reset-demo {
  width: 100%;
  margin-top: 0.75rem;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  padding: 1.25rem;
  background: #101828;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
}

.brand small,
.profile small {
  display: block;
  color: #b9c2d0;
}

.nav {
  display: grid;
  gap: 0.45rem;
}

.nav p {
  margin: 1rem 0 0.25rem;
  color: #98a2b3;
  font-size: 0.75rem;
  font-weight: 800;
}

.nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 0;
  border-radius: 0.7rem;
  padding: 0.8rem 0.9rem;
  color: #d0d5dd;
  background: transparent;
  text-align: left;
}

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

.profile {
  margin-top: auto;
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr) 2.4rem;
  gap: 0.7rem;
  align-items: center;
}

#avatar {
  display: inline-grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background: #fff;
  color: #101828;
  font-weight: 900;
}

.main {
  min-width: 0;
  padding: 1.4rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.topbar h1 {
  margin-bottom: 0.2rem;
}

.topbar p {
  color: var(--muted);
}

.top-actions,
.toolbar,
menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
}

.toolbar {
  margin: 1rem 0;
}

.toolbar input,
.toolbar select {
  width: auto;
  min-width: 12rem;
}

.toolbar textarea {
  min-width: min(100%, 34rem);
  flex: 1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.summary-band {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem;
  border-radius: 1rem;
  background: linear-gradient(135deg, #ffffff, #e9f7f5);
  border: 1px solid var(--line);
}

.summary-band h2 {
  margin-bottom: 0.2rem;
}

.todo-grid,
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(8rem, 1fr));
  gap: 0.75rem;
}

.metric,
.todo {
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: var(--panel);
}

.metric strong,
.todo strong {
  display: block;
  font-size: 1.6rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 1rem;
}

.order-card {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--panel);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  color: #344054;
  background: #eef2f6;
  font-size: 0.78rem;
  font-weight: 800;
}

.pill.good {
  color: var(--good);
  background: #e7f6ec;
}

.pill.warn {
  color: #99630d;
  background: #fff3d6;
}

.money {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.money span {
  color: var(--muted);
  font-size: 0.78rem;
}

.money strong {
  display: block;
}

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

table {
  width: 100%;
  min-width: 46rem;
  border-collapse: collapse;
}

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

th {
  background: #f8fafc;
  color: #475467;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.admin-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(18rem, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel {
  display: grid;
  gap: 0.9rem;
  border-radius: 0.9rem;
  padding: 1rem;
}

dialog {
  width: min(58rem, calc(100vw - 2rem));
  border: 0;
  border-radius: 1rem;
  padding: 0;
}

dialog::backdrop {
  background: rgba(16, 24, 40, 0.5);
}

.dialog-body {
  display: grid;
  gap: 1rem;
  padding: 1.1rem;
}

.close {
  justify-self: end;
}

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

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

.line-editor {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.6rem;
}

.mini-list {
  display: grid;
  gap: 0.5rem;
}

.mini-row {
  display: grid;
  grid-template-columns: 6rem 1fr 5rem 5rem 5rem 2rem;
  gap: 0.6rem;
  align-items: center;
  padding: 0.55rem;
  border-radius: 0.6rem;
  background: #f8fafc;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: 24rem;
  border-radius: 0.8rem;
  padding: 0.85rem 1rem;
  color: #fff;
  background: #101828;
  box-shadow: var(--shadow);
}

@media (max-width: 920px) {
  .login-screen,
  .app,
  .admin-layout {
    grid-template-columns: 1fr;
  }

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

  .todo-grid,
  .metrics,
  .money,
  .form-grid,
  .line-editor {
    grid-template-columns: 1fr;
  }

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