@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-soft: #fbfcfe;
  --line: #e4e9f2;
  --line-strong: #d8dfeb;
  --text: #1f2a44;
  --text-soft: #60708d;
  --primary: #335fd1;
  --primary-dark: #274db1;
  --primary-soft: #eef3ff;
  --shadow: 0 8px 24px rgba(31, 42, 68, 0.06);
  --shadow-soft: 0 4px 12px rgba(31, 42, 68, 0.04);
  --radius: 18px;
  --sidebar-width: 272px;

  --state-assigned-bg: #fff4e6;
  --state-assigned-text: #c26a08;
  --state-progress-bg: #fff8d9;
  --state-progress-text: #8a6700;
  --state-presented-bg: #eaf8ef;
  --state-presented-text: #1b7d45;
  --state-observed-bg: #fdeaea;
  --state-observed-text: #bd3131;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { border: 0; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top left, #f4f7ff 0, #ffffff 42%),
    linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
}

.login-wrapper { width: min(100%, 540px); padding: 24px; }
.login-card {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 42px 34px 30px;
}
.login-card h1 {
  margin: 0 0 10px;
  text-align: center;
  font-size: 3rem;
  letter-spacing: -.03em;
}
.login-subtitle {
  margin: 0 0 28px;
  text-align: center;
  color: var(--text-soft);
  font-size: 1.1rem;
}
.login-form { display: grid; gap: 14px; }
label {
  display: inline-block;
  font-size: .96rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 15px;
  background: #fbfcff;
  color: var(--text);
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(51,95,209,.45);
  box-shadow: 0 0 0 4px rgba(51,95,209,.10);
  background: #fff;
}
.form-error {
  min-height: 20px;
  color: #c33d3d;
  font-size: .92rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border-radius: 14px;
  padding: 13px 22px;
  font-weight: 700;
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease, border-color .18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-full { width: 100%; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 16px rgba(51,95,209,.18);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line-strong);
}
.forgot-link, .text-link {
  color: var(--primary);
  font-weight: 600;
}
.forgot-link { text-align: center; margin-top: 6px; }
.helper-box {
  border: 1px solid #d9e4ff;
  background: #f7faff;
  color: #46628f;
  border-radius: 14px;
  padding: 14px 16px;
  line-height: 1.45;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(8px);
  border-right: 1px solid var(--line);
  padding: 28px 18px;
}
.brand {
  font-size: 2.05rem;
  font-weight: 800;
  letter-spacing: -.03em;
  margin-bottom: 28px;
}
.menu { display: grid; gap: 10px; }
.menu-item {
  display: block;
  padding: 15px 18px;
  border-radius: 16px;
  font-size: 1.06rem;
  font-weight: 600;
  color: var(--text);
  transition: background-color .18s ease, color .18s ease;
}
.menu-item:hover { background: #f2f5fb; }
.menu-item.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.main-area {
  min-width: 0;
  display: grid;
  grid-template-rows: 78px 1fr;
}
.topbar {
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 30px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
}
.notification-group {
  position: relative;
  width: 22px;
  height: 22px;
  color: var(--text-soft);
}
.notification-group svg,
.icon-logout svg,
.inline-icon svg,
.doc-action svg,
.icon-action svg { width: 100%; height: 100%; display: block; }
.notification-badge {
  position: absolute;
  top: -8px;
  right: -10px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}
.current-user { font-size: 1rem; font-weight: 500; }
.icon-logout {
  width: 22px;
  height: 22px;
  color: var(--text-soft);
  transition: color .18s ease;
}
.icon-logout:hover { color: var(--primary); }

.content { padding: 30px; }
.content-header, .detail-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 24px;
}
.content-header h1, .detail-header h1 {
  margin: 0 0 8px;
  font-size: 2.4rem;
  letter-spacing: -.03em;
}
.muted { color: var(--text-soft); }
.muted-small { color: #7e8ca6; font-size: .92rem; }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 26px;
}
.status-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
  border-radius: 20px;
  box-shadow: var(--shadow-soft);
  padding: 22px 18px;
  text-align: center;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}
.status-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.status-card .label {
  color: var(--text-soft);
  font-size: .96rem;
  font-weight: 600;
  margin-bottom: 14px;
}
.status-card .count {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -.03em;
}

.panel {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.92);
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
  padding: 24px;
  margin-bottom: 24px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.panel-header h2 {
  margin: 0;
  font-size: 1.95rem;
  letter-spacing: -.03em;
}
.filters-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 18px;
  align-items: end;
}
.filters-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  align-items: end;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border-radius: 18px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}
thead th {
  text-align: left;
  background: #f6f8fc;
  color: var(--text);
  font-size: .95rem;
  font-weight: 700;
  padding: 16px 18px;
  white-space: nowrap;
}
tbody td {
  padding: 16px 18px;
  border-top: 1px solid #edf1f7;
  font-size: .96rem;
  vertical-align: middle;
}
tbody tr:hover { background: #fbfcff; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.badge.asignada { background: var(--state-assigned-bg); color: var(--state-assigned-text); }
.badge.en-proceso { background: var(--state-progress-bg); color: var(--state-progress-text); }
.badge.presentada { background: var(--state-presented-bg); color: var(--state-presented-text); }
.badge.observada { background: var(--state-observed-bg); color: var(--state-observed-text); }
.badge.active-user { background: #edf5ff; color: #285db7; }
.badge.inactive-user { background: #f1f2f6; color: #6c7280; }

.action-group {
  display: flex;
  align-items: center;
  gap: 14px;
}
.icon-action, .doc-action, .inline-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6f7d95;
  width: 18px;
  height: 18px;
  cursor: pointer;
  transition: color .18s ease, transform .18s ease;
}
.icon-action:hover, .doc-action:hover, .inline-icon:hover {
  color: var(--primary);
  transform: translateY(-1px);
}
.icon-action.danger { color: #cb3e3e; }
.icon-action.danger:hover { color: #a92a2a; }
.icon-action::after, .doc-action::after, .inline-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(.95);
  background: rgba(31,42,68,.95);
  color: #fff;
  font-size: .74rem;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}
.icon-action:hover::after, .doc-action:hover::after, .inline-icon:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.field-readonly {
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcff;
  padding: 14px 15px;
  display: flex;
  align-items: center;
  color: var(--text);
}
.fields-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 16px;
}
.fields-grid.single { grid-template-columns: 1fr; }
.detail-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.detail-meta .meta-main {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -.03em;
}
.detail-meta .meta-sub {
  color: #7b87a0;
  font-size: .95rem;
}
.accordion-item + .accordion-item { margin-top: 16px; }
.accordion-trigger {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
}
.accordion-trigger.open {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: #fbfcff;
}
.accordion-content {
  display: none;
  border: 1px solid var(--line);
  border-top: 0;
  background: #fff;
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
  padding: 20px;
}
.accordion-content.open { display: block; }
.accordion-arrow {
  width: 18px;
  height: 18px;
  transition: transform .18s ease;
}
.accordion-trigger.open .accordion-arrow { transform: rotate(90deg); }
.section-stack { display: grid; gap: 20px; }
.subcard {
  border: 1px solid #ebeff6;
  border-radius: 18px;
  padding: 18px;
  background: #fcfdff;
}
.subcard h4 {
  margin: 0 0 14px;
  font-size: 1.04rem;
}
.subcard-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.file-list {
  display: grid;
  gap: 12px;
}
.file-item {
  border: 1px solid #edf1f7;
  border-radius: 14px;
  padding: 14px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
}
.file-meta { display: grid; gap: 4px; }
.file-title { font-weight: 700; }
.file-name { color: var(--text-soft); font-size: .92rem; }
.file-name.strong { color: var(--text); font-weight: 600; }
.inline-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.comment-box {
  border: 1px solid #edf1f7;
  border-radius: 16px;
  padding: 14px 16px;
  background: #fff;
}
.comment-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: .92rem;
}
.comment-target {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5fb;
  color: #53709d;
  font-size: .78rem;
  font-weight: 700;
}
.comment-text { line-height: 1.5; color: #3d4a63; }
.comment-form {
  display: grid;
  gap: 14px;
  margin-top: 10px;
}
.comment-actions {
  display: flex;
  justify-content: flex-end;
}
.detail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
}
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: rgba(31,42,68,.96);
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 999;
}
.empty-state {
  padding: 22px;
  border: 1px dashed #dbe2ee;
  border-radius: 16px;
  color: var(--text-soft);
  text-align: center;
  background: #fbfcff;
}

@media (max-width: 1180px) {
  .cards-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .fields-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .filters-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .content { padding: 20px; }
  .cards-grid, .fields-grid, .filters-grid { grid-template-columns: 1fr; }
  .content-header, .detail-header, .panel-header { flex-direction: column; }
  .topbar { justify-content: flex-start; }
}
