:root {
  --bg: #071a33;
  --panel: #0d2747;
  --panel2: #123a63;
  --text: #eef6ff;
  --muted: #9fb7cf;
  --line: rgba(255,255,255,.12);
  --accent: #5ec7ff;
  --green: #1f8a5b;
  --red: #d94b4b;
  --orange: #d9902f;
  --white: #ffffff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, color-mix(in srgb, var(--panel2) 85%, white 10%) 0%, var(--bg) 45%, #030b17 100%);
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; }
button {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--accent);
  color: #03101d;
  font-weight: 700;
  transition: transform .08s ease, filter .08s ease, opacity .08s ease;
}
button:active { transform: translateY(1px) scale(.99); filter: brightness(.88); }
button.secondary { background: #213b58; color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--red); color: var(--white); }
button.good { background: var(--green); color: var(--white); }
button:disabled { opacity: .55; cursor: not-allowed; }
input, textarea, select {
  width: 100%;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
input[type="color"] { height: 44px; padding: 5px; }
select option { color: #111; }
textarea { min-height: 88px; resize: vertical; }
label { display: block; color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.hint, .muted { color: var(--muted); font-size: 13px; }

.app-shell { max-width: 1280px; margin: 0 auto; padding: 20px; }
.topbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 18px; position: sticky; top: 0; z-index: 10; background: linear-gradient(180deg, var(--bg), color-mix(in srgb, var(--bg) 90%, transparent)); padding: 10px 0; }
.topbar h1 { margin: 0; font-size: 24px; }
.topbar small { color: var(--muted); }
.top-actions { margin: 0; }
.card {
  background: color-mix(in srgb, var(--panel) 92%, black 8%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 18px 60px rgba(0,0,0,.25);
}
.login-card { max-width: 440px; margin: 9vh auto; }
.login-card h1 { margin-top: 0; }
.role-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.role-tabs button { background: #213b58; color: var(--text); }
.role-tabs button.active { background: var(--accent); color: #03101d; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.menu-tile { text-align: left; min-height: 110px; background: var(--panel2); color: var(--text); }
.menu-tile p { color: var(--muted); }
.section-title { margin: 24px 0 12px; color: var(--text); border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.message { margin: 12px 0; padding: 12px; border-radius: 12px; background: rgba(94,199,255,.12); border: 1px solid rgba(94,199,255,.25); }
.error { background: rgba(217,75,75,.14); border-color: rgba(217,75,75,.35); }

.people-box { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: rgba(255,255,255,.04); }
.people-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; margin-bottom: 12px; }
.check-row { display: flex; gap: 8px; align-items: center; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; color: var(--text); margin: 0; }
.check-row input { width: auto; min-width: 18px; height: 18px; }
.people-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 8px; }

.history-row { display: grid; grid-template-columns: 160px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.history-row:last-child { border-bottom: 0; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.detail-row { grid-template-columns: 280px 1fr 1px; }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.editor-card { padding-bottom: 90px; }
.style-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.editor-field { display: grid; grid-template-columns: 34px minmax(180px,1.2fr) minmax(120px,.8fr) 115px 130px 120px 120px 120px 120px auto; gap: 10px; align-items: end; padding: 12px 0; border-bottom: 1px solid var(--line); }
.editor-field:last-child { border-bottom: 0; }
.drag-handle { display:flex; align-items:center; justify-content:center; width:34px; height:42px; border-radius:10px; background:rgba(255,255,255,.08); border:1px solid var(--line); cursor:grab; user-select:none; font-weight:800; color:var(--muted); }
.editor-field.dragging { opacity: .45; }
.editor-field.drag-over { background: rgba(94,199,255,.08); outline: 1px dashed var(--accent); }
.dashboard-visible { align-self: end; min-height: 42px; }
.sticky-actions { position: sticky; bottom: 10px; z-index: 9; background: color-mix(in srgb, var(--panel) 88%, black 12%); border: 1px solid var(--line); padding: 10px; border-radius: 14px; }

.scroll-top { position: fixed; right: 18px; bottom: 18px; z-index: 50; width: 48px; height: 48px; border-radius: 50%; padding: 0; box-shadow: 0 8px 30px rgba(0,0,0,.35); }

.tv-page { padding: 12px; height: 100vh; overflow: hidden; display: flex; flex-direction: column; background: var(--bg); }
.tv-page-rows { gap: 8px; }
.tv-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 6px; flex: 0 0 auto; }
.tv-header h1 { margin: 0; font-size: clamp(22px, 2.2vw, 42px); letter-spacing: .5px; }
.tv-right { display: flex; align-items: center; gap: 12px; }
.tv-rows { flex: 1 1 auto; min-height: 0; display: grid; grid-template-rows: repeat(var(--tv-row-count, 6), minmax(0, 1fr)); gap: 8px; }
.tv-section { min-height: 0; display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px; align-items: stretch; }
.tv-section-label { background: color-mix(in srgb, var(--panel) 92%, black 8%); border: 1px solid var(--line); border-radius: 14px; padding: 10px; display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 800; color: var(--text); font-size: clamp(14px, 1vw, 22px); line-height: 1.1; }
.tv-section.summary-row .tv-section-label { background: color-mix(in srgb, var(--accent) 24%, var(--panel) 76%); }
.tv-section-grid { min-height: 0; display: grid; grid-template-columns: repeat(var(--section-cols, 4), minmax(0, 1fr)); gap: 8px; }
.summary-row .tv-section-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile { background: var(--field-bg, color-mix(in srgb, var(--panel2) 95%, black 5%)); border: 1px solid var(--line); border-radius: 14px; padding: 9px 10px; min-height: 0; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
.tile .label { color: var(--field-label, var(--muted)); font-size: clamp(10px, .78vw, 14px); line-height: 1.15; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile .value { font-weight: 800; font-size: clamp(18px, 1.55vw, 32px); line-height: 1.02; word-break: break-word; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.tile.status.good { background: linear-gradient(145deg, var(--green), color-mix(in srgb, var(--panel) 88%, black 12%)); }
.tile.status.bad { background: linear-gradient(145deg, var(--red), color-mix(in srgb, var(--panel) 88%, black 12%)); }
.tile.status.neutral { background: linear-gradient(145deg, rgba(95,117,140,.75), color-mix(in srgb, var(--panel) 88%, black 12%)); }
.tile.text-block .value { font-size: clamp(13px, 1vw, 20px); font-weight: 600; white-space: pre-wrap; -webkit-line-clamp: 4; }
.tile.wide { grid-column: 1 / -1; }
.refresh-note { color: var(--muted); font-size: 13px; margin-top: 4px; }

@media (max-width: 1100px) {
  .editor-field { grid-template-columns: 34px 1fr 1fr; }
  .editor-field > div, .editor-field > label { min-width: 0; }
}

@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 1fr; }
  .row-actions { justify-content: flex-start; }
  .editor-field { grid-template-columns: 1fr; }
  .drag-handle { width: 100%; }
  .tv-rows { display: block; overflow: auto; }
  .tv-section { grid-template-columns: 1fr; margin-bottom: 10px; }
  .tv-section-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .tile.wide { grid-column: span 2; }
  .people-actions { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
}
