:root {
  --bg: #f4f6f4;
  --panel: #ffffff;
  --text: #152125;
  --muted: #637174;
  --line: #dbe2de;
  --navy: #17324d;
  --green: #2f8f5b;
  --amber: #b68232;
  --red: #b43c2e;
  --shadow: 0 16px 42px rgba(20, 35, 43, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-box {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 26px;
  text-align: center;
}

.login-logo {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  margin: 0 auto 16px;
  display: block;
}

.login-box h1 {
  margin-bottom: 22px;
}

.login-box label {
  text-align: left;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 3;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 260px;
}

.avatar {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.brand p,
.status,
.muted {
  color: var(--muted);
  font-size: 13px;
}

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

.tab,
button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
}

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

.tab.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

main {
  width: min(1240px, calc(100% - 32px));
  margin: 24px auto 44px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

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

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

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

.checkline {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
}

.checkline input {
  width: 18px;
  height: 18px;
}

.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 650;
}

.danger {
  color: var(--red);
  border-color: rgba(180, 60, 46, 0.35);
}

.empty {
  min-height: 280px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

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

.priority-summary {
  border: 2px solid rgba(182, 130, 50, 0.55);
  background: #fff8ec;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}

.priority-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.priority-head h3 {
  font-size: 17px;
  margin-bottom: 5px;
}

.priority-head p {
  color: var(--text);
  font-size: 14px;
}

.status-badges {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border-radius: 999px;
  padding: 6px 10px;
  background: #edf4ef;
  color: #1e6840;
  font-size: 12px;
  font-weight: 700;
}

.status-badge.risk {
  background: #ffe5df;
  color: #8e261c;
}

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

.priority-grid h4 {
  margin: 0 0 7px;
}

.priority-grid ul {
  margin: 0;
  padding-left: 18px;
}

.compact-kv {
  margin-top: 12px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 76px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.metric strong {
  font-size: 18px;
  overflow-wrap: anywhere;
}

.document-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.block {
  margin-top: 16px;
}

.block h3 {
  font-size: 15px;
  margin-bottom: 8px;
}

.block h4 {
  font-size: 13px;
  margin: 12px 0 7px;
}

.kv {
  display: grid;
  gap: 7px;
}

.kv div {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 7px 0;
}

.kv span {
  color: var(--muted);
}

.doubts {
  border: 1px solid rgba(182, 130, 50, 0.35);
  background: #fff8ec;
  border-radius: 8px;
  padding: 12px;
}

.doubts ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.ai-block,
.coherence-block,
.default-control-block,
.cso-block,
.regulation-block,
.sources-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.ai-block {
  background: #fbfaf6;
}

.cso-block {
  background: #f8fbf9;
}

.coherence-block {
  background: #f7fbfb;
}

.default-control-block {
  background: #fffdf7;
}

.regulation-block {
  background: #f7f9fc;
}

.sources-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.source-item {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.source-item strong,
.source-item a {
  overflow-wrap: anywhere;
}

.source-item p {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0;
}

.history-list,
.user-list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: #edf4ef;
  color: #1e6840;
  font-size: 12px;
  margin-top: 7px;
}

@media (max-width: 860px) {
  .app-header,
  .layout {
    display: grid;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
  }

  .kv div {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .priority-head,
  .priority-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .status-badges {
    justify-content: flex-start;
  }

  .list-item {
    grid-template-columns: 1fr;
  }
}
