:root {
  --paper: #f3efe5;
  --paper-deep: #e7e0d1;
  --ink: #18201b;
  --muted: #687169;
  --line: #c9c4b8;
  --forest: #1e4d38;
  --forest-bright: #2d7957;
  --cream: #fffdf7;
  --rust: #a34d32;
  --amber: #a67423;
  --shadow: 0 22px 55px rgba(34, 41, 36, .09);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(24, 32, 27, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 32, 27, .025) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: "Aptos", "Microsoft YaHei UI", sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(45, 121, 87, .35); outline-offset: 3px; }

.eyebrow, .section-kicker {
  margin: 0 0 10px;
  color: var(--forest-bright);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
}

.login-page { display: grid; place-items: center; padding: 28px; }

.login-shell {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  width: min(1040px, 100%);
  min-height: 620px;
  overflow: hidden;
  border: 1px solid rgba(24, 32, 27, .2);
  border-radius: 28px;
  background: var(--cream);
  box-shadow: var(--shadow);
  animation: rise-in .55s cubic-bezier(.2,.8,.2,1) both;
}

.login-intro {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(42px, 7vw, 86px);
  color: #f7f2e7;
  background:
    radial-gradient(circle at 75% 25%, rgba(121, 173, 127, .28), transparent 26%),
    linear-gradient(145deg, #193b2c, #10261c);
}

.login-intro::after {
  content: "";
  position: absolute;
  right: -80px;
  bottom: -100px;
  width: 320px;
  height: 320px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 50%;
  box-shadow: 0 0 0 38px rgba(255,255,255,.035), 0 0 0 76px rgba(255,255,255,.025);
}

.login-intro .eyebrow { color: #a9c9ad; }
.login-intro h1, .hero h1 {
  margin: 0;
  font-family: Georgia, "Microsoft YaHei", serif;
  font-weight: 500;
  letter-spacing: -.045em;
}
.login-intro h1 { font-size: clamp(3.2rem, 7vw, 5.6rem); line-height: .96; }
.login-copy { max-width: 340px; margin: 28px 0; color: #c9d5ca; font-size: 1.05rem; }
.server-mark { display: flex; align-items: center; gap: 9px; margin-top: 56px; font-size: .82rem; color: #b9c8bb; }
.server-mark span, .server-status i { width: 8px; height: 8px; border-radius: 50%; background: #79c28d; box-shadow: 0 0 0 5px rgba(121,194,141,.12); }

.login-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(36px, 6vw, 68px); }
.login-panel h2 { margin: 0; font-family: Georgia, "Microsoft YaHei", serif; font-size: 2.25rem; font-weight: 500; }
.login-form { display: grid; gap: 22px; margin-top: 42px; }
.login-form label { display: grid; gap: 9px; font-size: .82rem; font-weight: 700; }
.login-form input { width: 100%; padding: 14px 2px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--ink); }
.login-form input:focus { border-color: var(--forest-bright); outline: 0; }
.primary-button, .secondary-button, .danger-button, .refresh-button, .text-button, .icon-button {
  border: 0;
  border-radius: 999px;
  transition: transform .18s ease, background .18s ease, color .18s ease, opacity .18s ease;
}
.primary-button { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; color: #fff; background: var(--forest); font-weight: 750; }
.primary-button:hover { transform: translateY(-2px); background: #173e2c; }
.primary-button.compact { display: inline-flex; padding: 11px 18px; }
.form-error { margin: 28px 0 -18px; padding: 12px 14px; border-left: 3px solid var(--rust); background: rgba(163,77,50,.08); color: #78341f; font-size: .86rem; }
.security-note { margin: 22px 0 0; color: var(--muted); font-size: .75rem; text-align: center; }

.site-header { display: flex; justify-content: space-between; align-items: center; min-height: 76px; padding: 0 clamp(22px, 5vw, 72px); border-bottom: 1px solid var(--line); background: var(--paper); }
.wordmark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-family: Georgia, serif; font-weight: 700; text-decoration: none; }
.wordmark-dot { width: 13px; height: 13px; border: 3px solid var(--forest); border-radius: 50%; }
.header-actions, .server-status { display: flex; align-items: center; gap: 18px; }
.server-status { gap: 9px; color: var(--forest); font-size: .8rem; font-weight: 750; }
.text-button { padding: 8px 0; background: transparent; color: var(--muted); }
.text-button:hover { color: var(--ink); }

.dashboard-shell { width: min(1240px, calc(100% - 44px)); margin: 0 auto; padding: clamp(56px, 8vw, 100px) 0 80px; }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 70px; }
.hero h1 { font-size: clamp(3.9rem, 9vw, 7.8rem); line-height: .95; }
.hero p:not(.eyebrow) { margin: 16px 0 0; color: var(--muted); font-size: 1.1rem; }
.refresh-button { padding: 12px 18px; border: 1px solid var(--line); background: rgba(255,253,247,.66); color: var(--ink); font-weight: 700; }
.refresh-button:hover { transform: translateY(-2px); border-color: var(--ink); }
.refresh-button.is-loading span { display: inline-block; animation: spin .8s linear infinite; }

.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; margin-bottom: 22px; }
.section-heading h2 { margin: 0; font-family: Georgia, "Microsoft YaHei", serif; font-size: 1.45rem; }
.section-heading p { margin: 0; color: var(--muted); font-size: .82rem; }
.project-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; }
.project-card {
  grid-column: span 4;
  position: relative;
  min-height: 290px;
  display: flex;
  flex-direction: column;
  padding: 25px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,253,247,.86);
  box-shadow: 0 6px 22px rgba(30,40,33,.045);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  animation: card-in .4s ease both;
}
.project-card:hover { transform: translateY(-4px); border-color: #9e9a90; box-shadow: 0 18px 36px rgba(30,40,33,.09); }
.project-card:nth-child(4n+2) { animation-delay: .06s; }
.project-card:nth-child(4n+3) { animation-delay: .12s; }
.project-card:nth-child(4n+4) { animation-delay: .18s; }
.project-card.workspace { background: rgba(231,224,209,.62); border-style: dashed; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.project-type { margin: 0 0 8px; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.project-name { margin: 0; font-family: Georgia, "Microsoft YaHei", serif; font-size: 1.55rem; font-weight: 600; }
.status-badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border-radius: 999px; background: rgba(45,121,87,.09); color: var(--forest-bright); font-size: .7rem; font-weight: 800; }
.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-badge.stopped, .status-badge.error { color: var(--rust); background: rgba(163,77,50,.08); }
.status-badge.workspace { color: var(--amber); background: rgba(166,116,35,.09); }
.project-meta { display: grid; gap: 9px; margin: 28px 0 22px; padding: 17px 0; border-block: 1px solid rgba(201,196,184,.7); }
.meta-row { display: flex; justify-content: space-between; gap: 16px; font-size: .78rem; }
.meta-row dt { color: var(--muted); }
.meta-row dd { margin: 0; max-width: 65%; overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.meta-row a { color: var(--forest); text-decoration-color: rgba(30,77,56,.25); text-underline-offset: 3px; }
.card-actions { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.card-button { padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink); font-size: .75rem; font-weight: 700; transition: background .18s ease, border .18s ease, transform .18s ease; }
.card-button:hover { transform: translateY(-1px); border-color: var(--forest); background: rgba(30,77,56,.055); }
.card-button.stop:hover { border-color: var(--rust); color: var(--rust); background: rgba(163,77,50,.055); }
.card-button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.skeleton-card { min-height: 290px; background: linear-gradient(110deg, rgba(255,255,255,.45) 30%, rgba(255,255,255,.85) 45%, rgba(255,255,255,.45) 60%); background-size: 220% 100%; animation: shimmer 1.2s linear infinite; }

dialog { width: min(760px, calc(100% - 30px)); padding: 0; border: 1px solid var(--line); border-radius: 22px; background: var(--cream); color: var(--ink); box-shadow: 0 30px 90px rgba(16,28,20,.28); }
dialog::backdrop { background: rgba(17,26,20,.56); backdrop-filter: blur(4px); }
.dialog-header { display: flex; justify-content: space-between; align-items: start; padding: 24px 26px 18px; border-bottom: 1px solid var(--line); }
.dialog-header h2, .confirm-dialog h2 { margin: 0; font-family: Georgia, "Microsoft YaHei", serif; }
.icon-button { width: 36px; height: 36px; background: var(--paper-deep); color: var(--ink); font-size: 1.4rem; }
.logs-dialog pre { min-height: 380px; max-height: 56vh; margin: 0; padding: 22px 26px; overflow: auto; background: #152219; color: #d9e8dc; font: .78rem/1.62 "Cascadia Mono", "Microsoft YaHei UI", monospace; white-space: pre-wrap; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 24px; }
.secondary-button, .danger-button { padding: 11px 17px; font-weight: 750; }
.secondary-button { border: 1px solid var(--line); background: transparent; color: var(--ink); }
.danger-button { background: var(--rust); color: white; }
.danger-button[data-action="start"] { background: var(--forest); }
.confirm-dialog { max-width: 460px; padding: 27px; }
.confirm-dialog > p:not(.section-kicker) { color: var(--muted); line-height: 1.65; }
.confirm-dialog .dialog-footer { padding: 18px 0 0; }

.toast-region { position: fixed; right: 24px; bottom: 24px; display: grid; gap: 9px; z-index: 20; }
.toast { min-width: 250px; padding: 13px 16px; border: 1px solid rgba(255,255,255,.2); border-radius: 12px; background: #173e2c; color: white; box-shadow: var(--shadow); animation: toast-in .25s ease both; }
.toast.error { background: #78341f; }

@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } }
@keyframes card-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position-x: -220%; } }

@media (max-width: 940px) {
  .project-card { grid-column: span 6; }
  .login-shell { grid-template-columns: 1fr; }
  .login-intro { min-height: 300px; padding: 42px; }
  .login-intro h1 { font-size: 3.7rem; }
  .server-mark { margin-top: 28px; }
}

@media (max-width: 620px) {
  .login-page { padding: 0; }
  .login-shell { min-height: 100vh; border: 0; border-radius: 0; }
  .login-intro { min-height: 260px; padding: 34px 25px; }
  .login-panel { padding: 38px 25px; }
  .site-header { padding-inline: 18px; }
  .server-status { display: none; }
  .dashboard-shell { width: min(100% - 28px, 1240px); padding-top: 48px; }
  .hero { align-items: flex-start; flex-direction: column; margin-bottom: 50px; }
  .hero h1 { font-size: 4rem; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .project-card { grid-column: span 12; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
