:root {
  --bg: #151614;
  --rail: #10110f;
  --surface: #20221f;
  --surface-2: #272a25;
  --surface-3: #30342e;
  --line: #3c4138;
  --line-strong: #555d4e;
  --text: #f1f2ee;
  --muted: #b7bcae;
  --soft: #858d7d;
  --accent: #6fae73;
  --accent-strong: #8ccf8f;
  --warn: #d0a644;
  --danger: #cf665f;
  --success: #65b982;
  --info: #7aa7bd;
  --radius: 8px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  --font: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
}

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

button {
  letter-spacing: 0;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding: 18px;
  background: var(--rail);
  border-right: 1px solid var(--line);
}

.brandBlock {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
}

.brandMark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #1b221b;
  color: var(--accent-strong);
  font-weight: 800;
}

.brandBlock h1 {
  margin: 0;
  font-size: 1.05rem;
}

.brandBlock p,
.panelHeader p,
.topBar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.sidebarNav {
  display: grid;
  gap: 8px;
  margin-top: 26px;
}

.navBtn,
.primaryBtn,
.secondaryBtn,
.dangerBtn,
.successBtn,
.iconBtn {
  min-height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  cursor: pointer;
}

.navBtn {
  padding: 10px 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.navBtn:hover,
.navBtn.active {
  background: var(--surface);
  border-color: var(--accent);
}

.sidebarFooter {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: #151713;
}

.sidebarFooter strong {
  color: var(--text);
  font-size: 0.92rem;
}

.mainContent {
  min-width: 0;
}

.topBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 74px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #181a17;
}

.topBar h2 {
  margin: 0;
  font-size: 1.25rem;
}

.topControls {
  display: grid;
  grid-template-columns: minmax(220px, 360px) minmax(190px, 250px) auto;
  gap: 10px;
}

.inputControl,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #171915;
  outline: none;
}

.field textarea {
  min-height: 78px;
  resize: vertical;
}

.inputControl:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
}

.dashboardView {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(460px, 1.55fr) minmax(300px, 0.9fr);
  grid-template-areas:
    "claims detail important"
    "claims detail suggestions";
  gap: 14px;
  padding: 14px;
  align-items: start;
}

.secondaryView {
  padding: 14px;
}

.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.claimsPanel {
  grid-area: claims;
}

.detailPanel {
  grid-area: detail;
}

.importantPanel {
  grid-area: important;
}

.suggestionsPanel {
  grid-area: suggestions;
}

.fullPanel {
  min-height: calc(100vh - 110px);
}

.panelHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.panelHeader h3 {
  margin: 0;
  font-size: 0.98rem;
}

.panelActions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.primaryBtn,
.secondaryBtn,
.dangerBtn,
.successBtn {
  padding: 8px 12px;
  font-weight: 700;
}

.primaryBtn {
  background: var(--accent);
  border-color: var(--accent);
  color: #081109;
}

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

.secondaryBtn {
  background: #1a1c18;
  color: var(--text);
}

.secondaryBtn:hover {
  border-color: var(--line-strong);
  background: var(--surface-3);
}

.dangerBtn {
  background: #2b1d1c;
  border-color: #7d403b;
  color: #ffd8d5;
}

.successBtn {
  background: #1b2a20;
  border-color: #407d52;
  color: #d7ffe0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.metricStrip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.metricStrip div {
  display: grid;
  gap: 3px;
  padding: 10px;
  background: #1a1d18;
}

.metricStrip span {
  color: var(--muted);
  font-size: 0.74rem;
}

.metricStrip strong {
  font-size: 1.05rem;
}

.claimsList,
.stackList,
.rulesList,
.draftsList {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.claimsList {
  max-height: calc(100vh - 190px);
  overflow: auto;
}

.claimRow,
.taskRow,
.suggestionRow,
.recordRow,
.activityRow,
.draftRow,
.ruleRow {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #191b17;
}

.claimRow {
  display: grid;
  gap: 8px;
  padding: 11px;
  cursor: pointer;
}

.claimRow:hover,
.claimRow.active {
  border-color: var(--accent);
  background: #1d231b;
}

.claimTop,
.rowTop {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.claimNumber,
.rowTitle {
  font-weight: 800;
}

.subText,
.metaText {
  color: var(--muted);
  font-size: 0.82rem;
}

.badgeLine {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.75rem;
  background: #20231d;
}

.badge.warn {
  border-color: #7a6429;
  color: #ffd978;
}

.badge.danger {
  border-color: #7d403b;
  color: #ffc4bf;
}

.badge.success {
  border-color: #407d52;
  color: #c6ffd1;
}

.detailBody {
  padding: 14px;
}

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

.detailSection {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #191b17;
  padding: 12px;
}

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

.detailSection h4,
.suggestionBox h4 {
  margin: 0 0 9px;
  font-size: 0.92rem;
}

.definitionGrid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 7px 10px;
  font-size: 0.88rem;
}

.definitionGrid span:nth-child(odd) {
  color: var(--muted);
}

.taskRow,
.suggestionRow,
.recordRow,
.activityRow,
.draftRow,
.ruleRow {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.taskActions,
.draftActions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.rulesToolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.dangerText {
  color: #ffb6ad;
  border-color: #7d403b;
}

.linkBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.smallBtn {
  min-height: 30px;
  padding: 5px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  color: var(--text);
  background: #22251f;
  cursor: pointer;
}

.smallBtn:hover {
  border-color: var(--accent);
}

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

.suggestionBox {
  padding: 12px;
}

.compact {
  padding: 0;
}

.emptyState {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
}

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

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label,
.checkGroupLabel {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.checkGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #171915;
}

.checkGrid label,
.flagGrid label {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.2;
}

.checkGrid input[type="checkbox"],
.flagGrid input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  box-sizing: border-box;
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: #f0f2ed;
  align-self: center;
  justify-self: center;
}

.checkGrid input[type="checkbox"]:checked,
.flagGrid input[type="checkbox"]:checked {
  border-color: #228427;
  background-color: #16811d;
  background-image: linear-gradient(45deg, transparent 45%, #ffffff 45%, #ffffff 58%, transparent 58%),
    linear-gradient(-45deg, transparent 45%, #ffffff 45%, #ffffff 58%, transparent 58%);
  background-position: 7px 3px, 2px 5px;
  background-size: 8px 11px, 6px 8px;
  background-repeat: no-repeat;
}

.documentCheckGrid {
  align-items: start;
}

.checkSubgroup {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #141611;
}

.checkSubgroup > span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

.modal {
  max-width: min(860px, calc(100vw - 32px));
  width: 860px;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  color: var(--text);
  background: transparent;
}

.alarmModal {
  max-width: min(560px, calc(100vw - 32px));
}

.alarmTask {
  display: grid;
  gap: 8px;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.modalCard {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modalHeader,
.modalFooter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

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

.modalHeader h3 {
  margin: 0;
}

.iconBtn {
  width: 34px;
  background: #1a1c18;
  color: var(--text);
}

.modalBody {
  max-height: 70vh;
  overflow: auto;
  padding: 14px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #1f251f;
  color: var(--text);
  box-shadow: var(--shadow);
}

.authView {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}

.authCard {
  width: min(440px, 100%);
  display: grid;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.authCard h2 {
  margin: 0;
}

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

.authForm {
  display: grid;
  gap: 11px;
}

.authMessage {
  min-height: 20px;
  margin: 0;
  padding: 10px;
  border: 1px solid #7d403b;
  border-radius: var(--radius);
  color: #ffc4bf;
  background: #2b1d1c;
  font-size: 0.86rem;
}

.authMessage:empty {
  display: none;
}

.authMessage[data-type="success"] {
  border-color: #407d52;
  color: #d7ffe0;
  background: #1b2a20;
}

.authFootnote {
  font-size: 0.78rem;
}

.rulesIntro {
  padding: 12px 14px 0;
  color: var(--muted);
}

.draftBody {
  white-space: pre-wrap;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #151713;
}

.actionOverlay {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: grid;
  justify-items: end;
  gap: 10px;
}

.actionMenuToggle {
  min-width: 108px;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #081109;
  font-weight: 800;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.actionMenu {
  width: min(390px, calc(100vw - 36px));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.actionMenuHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.actionMenuHeader h3 {
  margin: 0;
  font-size: 0.95rem;
}

.actionMenuHeader p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.draftsWorkbench {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.draftClaimContext,
.draftSection,
.templateCard,
.guideBlock {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #191b17;
}

.draftClaimContext {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.draftClaimContext h4,
.draftSection h4,
.templateCategory h5,
.guideBlock h5 {
  margin: 0;
}

.draftClaimContext p,
.templateCard p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.draftSection {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.templateCategory {
  display: grid;
  gap: 8px;
}

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

.templateCard {
  display: grid;
  align-content: space-between;
  gap: 10px;
  min-height: 132px;
  padding: 10px;
}

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

.guideBlock {
  padding: 10px;
}

.guideBlock ul,
.plainList {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 0.86rem;
}

.guideBlock li,
.plainList li {
  margin: 5px 0;
}

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

.draftEditor {
  min-height: 380px;
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.35;
}

@media (max-width: 1280px) {
  .dashboardView {
    grid-template-columns: minmax(300px, 0.9fr) minmax(430px, 1.2fr);
    grid-template-areas:
      "claims detail"
      "important suggestions";
  }

  .claimsList {
    max-height: 520px;
  }
}

@media (max-width: 900px) {
  .appShell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .topBar,
  .panelHeader {
    align-items: stretch;
    flex-direction: column;
  }

  .topControls,
  .dashboardView,
  .detailGrid,
  .formGrid,
  .actionGrid,
  .templateGrid,
  .reviewGuide,
  .splitGuide {
    grid-template-columns: 1fr;
  }

  .dashboardView {
    grid-template-areas:
      "claims"
      "important"
      "suggestions"
      "detail";
  }

  .draftClaimContext {
    align-items: stretch;
    flex-direction: column;
  }

  .detailSection.wide,
  .field.full {
    grid-column: auto;
  }
}
