:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #fbfcfd;
  --text: #1f2937;
  --muted: #667085;
  --line: #d0d5dd;
  --line-soft: #eaecf0;
  --accent: #7a3510;
  --accent-hover: #612a0d;
  --accent-soft: #fff4ed;
  --good: #067647;
  --bad: #b42318;
  --warn: #b54708;
  --blue: #175cd3;
  --shadow: 0 18px 50px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, "Segoe UI", Arial, sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; }
.num { text-align: right; }

.login-page {
  min-height: 100vh;
  background: #fff;
  display: grid;
  grid-template-columns: minmax(320px, 520px) 1fr;
}

.brand-corner {
  position: fixed;
  top: 32px;
  left: 38px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 800;
  z-index: 2;
}

.brand-corner img,
.side-logo img {
  display: block;
  object-fit: contain;
}

.brand-corner img { width: 148px; max-height: 54px; }

.login-panel {
  align-self: center;
  margin: 130px 44px 44px;
}

.login-card {
  width: 100%;
  max-width: 460px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  padding: 34px;
  box-shadow: var(--shadow);
}

.login-hero {
  background:
    radial-gradient(circle at top left, rgba(122, 53, 16, .20), transparent 34%),
    linear-gradient(135deg, #fff7ed, #f8fafc 48%, #ffffff);
  border-left: 1px solid var(--line-soft);
  display: grid;
  place-items: center;
  padding: 50px;
}

.hero-card {
  max-width: 620px;
  border: 1px solid rgba(122, 53, 16, .12);
  border-radius: 28px;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(10px);
  padding: 36px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: clamp(28px, 3vw, 40px); }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }

.form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.field { display: grid; gap: 7px; font-weight: 650; }
.field small { color: var(--muted); font-weight: 400; }

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

textarea { min-height: 92px; resize: vertical; }
.input:focus, .select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(122, 53, 16, .12);
}

.password-wrap { display: flex; gap: 8px; }
.password-wrap .input { flex: 1; }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 500;
}

.btn {
  border: 0;
  border-radius: 11px;
  padding: 11px 14px;
  font-weight: 760;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.secondary { border: 1px solid var(--line); background: #fff; color: var(--text); }
.btn.danger { background: #fef3f2; color: var(--bad); }
.btn.link { background: transparent; color: var(--accent); padding: 4px; justify-content: flex-start; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.small { padding: 7px 10px; border-radius: 9px; font-size: 12px; }

.error { color: var(--bad); min-height: 19px; }

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

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

.side-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.side-logo img { width: 124px; max-height: 46px; }
.side-logo small { display: block; color: var(--muted); }

.nav { display: grid; gap: 5px; overflow: auto; padding-right: 2px; }
.nav-group {
  margin: 14px 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.nav-btn {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
}

.nav-btn:hover { background: #f9fafb; }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 850; }

.side-account {
  margin-top: auto;
  border-top: 1px solid var(--line-soft);
  padding-top: 16px;
  display: grid;
  gap: 8px;
}

.side-account small { display: block; color: var(--muted); }

.main {
  min-width: 0;
  padding: 26px;
}

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

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

.studio-switch { min-width: 260px; }
.notice { min-height: 22px; margin-bottom: 12px; color: var(--muted); }

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

.card {
  grid-column: 1 / -1;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}

.card.half { grid-column: span 6; }
.metric { grid-column: span 3; }
.metric span { color: var(--muted); }
.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 25px;
  letter-spacing: -.02em;
}
.metric.lead { background: #2f241f; color: #fff; border-color: #2f241f; }
.metric.lead span, .metric.lead strong { color: #fff; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 14px;
}
.toolbar .field { min-width: 170px; margin: 0; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  background: #fff;
}

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

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

th {
  color: var(--muted);
  background: #fafafa;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}

tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }

.tree-page {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.tree-page > .card { grid-column: auto; }
.tree-card { position: sticky; top: 26px; }
.tree-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.tree-list {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.tree-node {
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  background: #fff;
  padding: 12px;
  text-align: left;
}

.tree-node:hover { border-color: var(--accent); background: #fffaf7; }
.tree-node.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 4px rgba(122, 53, 16, .08); }
.tree-node-title { display: block; font-weight: 850; color: var(--text); }
.tree-node-meta { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }

.detail-card { min-height: 640px; }
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.info-grid > div {
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  background: var(--surface-soft);
  padding: 13px;
}

.info-grid span { display: block; color: var(--muted); font-size: 12px; }
.info-grid strong { display: block; margin-top: 6px; }
.compact-form { border-top: 1px solid var(--line-soft); padding-top: 16px; }

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.chip.good { background: #ecfdf3; color: var(--good); }
.chip.bad { background: #fef3f2; color: var(--bad); }
.chip.warn { background: #fffaeb; color: var(--warn); }
.chip.blue { background: #eff8ff; color: var(--blue); }

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

.tile {
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
  background: #fff;
  text-align: left;
}
.tile img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: #f2f4f7;
}
.tile span { display: block; padding: 9px; color: var(--muted); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, .62);
}

.modal-card {
  width: min(980px, 100%);
  max-height: 90vh;
  overflow: auto;
  border-radius: 18px;
  background: #fff;
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal img, .modal video {
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  display: block;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: 420px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  padding: 13px 15px;
  box-shadow: var(--shadow);
}

.toast.bad { border-color: #fecdca; color: var(--bad); }

@media (max-width: 1020px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .metric { grid-column: span 6; }
  .card.half { grid-column: 1 / -1; }
  .tree-page { grid-template-columns: 1fr; }
  .tree-card { position: static; }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .brand-corner { position: static; padding: 22px 24px 0; }
  .brand-corner img { width: 130px; }
  .login-panel { margin: 26px 18px; }
  .login-card { padding: 24px; }
  .main { padding: 18px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .studio-switch { width: 100%; min-width: 0; }
  .metric { grid-column: 1 / -1; }
  .info-grid { grid-template-columns: 1fr; }
}
