/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg: #eef0f5;
  --color-surface: #ffffff;
  --color-border: #d8dde4;
  --color-text: #1a1f2e;
  --color-text-muted: #6b7280;
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-danger: #dc2626;
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-allocated: #7c3aed;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.08);
  --nav-height: 60px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html, body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Navigation ===== */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  height: var(--nav-height);
  display: flex; align-items: center; gap: 32px;
  padding: 0 24px;
}

.nav__brand a {
  font-weight: 700; font-size: 18px; color: var(--color-primary);
  text-decoration: none; letter-spacing: -0.3px;
}
.nav__brand-link { display: flex; align-items: center; gap: 8px; }
.nav__brand-icon { display: block; flex-shrink: 0; border-radius: 6px; }

.nav__links {
  list-style: none; display: flex; gap: 4px; flex: 1;
}

.nav__links a {
  display: block; padding: 6px 12px; border-radius: 6px;
  color: var(--color-text-muted); font-weight: 500;
  text-decoration: none; transition: background .15s, color .15s;
}
.nav__links a:hover, .nav__links a.active {
  background: #f0f0ff; color: var(--color-primary);
}

.nav__user {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--color-text-muted);
}
.nav__user a { font-size: 13px; }

/* ===== Main layout ===== */
.main {
  max-width: 1100px; margin: 0 auto; padding: 32px 24px;
}

/* ===== Page header ===== */
.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 700; }

/* ===== Cards ===== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card__title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.card__hint { color: var(--color-text-muted); font-size: 14px; margin-bottom: 16px; }
.card--form { max-width: 560px; }

/* ===== Dashboard grid ===== */
.dashboard-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 18px; border-radius: 6px; font-size: 14px; font-weight: 500;
  border: none; cursor: pointer; text-decoration: none; transition: background .15s;
}
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-hover); text-decoration: none; }
.btn--secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn--secondary:hover { background: var(--color-bg); text-decoration: none; }
.btn--full { width: 100%; }
.btn--lg { padding: 12px 24px; font-size: 16px; }

.btn-link {
  background: none; border: none; cursor: pointer;
  color: var(--color-primary); font-size: 14px; padding: 0; font-family: inherit;
}
.btn-link:hover { text-decoration: underline; }

/* ===== Badges ===== */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; text-transform: capitalize;
}
.badge--active    { background: #dcfce7; color: #15803d; }
.badge--inactive  { background: #f3f4f6; color: #6b7280; }
.badge--allocated { background: #ede9fe; color: #7c3aed; }
.badge--submitted { background: #fef9c3; color: #a16207; }
.badge--lg { padding: 4px 14px; font-size: 14px; }
.badge--role-admin { background: #fce7f3; color: #9d174d; }
.badge--role-user  { background: #e0f2fe; color: #0369a1; }
.badge--assigned   { background: #dbeafe; color: #1d4ed8; }
.badge--my-assignment { background: #fef3c7; color: #92400e; }
.badge--executed      { background: #bbf7d0; color: #14532d; }

/* ===== Table ===== */
.table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.table th {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600; color: var(--color-text-muted); font-size: 13px;
}
.table td {
  padding: 12px 12px; border-bottom: 1px solid var(--color-border);
}
.table tr:last-child td { border-bottom: none; }
.table__actions { display: flex; gap: 12px; align-items: center; }
.empty-state { color: var(--color-text-muted); text-align: center; padding: 32px 0; }

/* ===== Forms ===== */
.field { margin-bottom: 20px; }
.field__label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }

.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--color-border); border-radius: 6px;
  font-size: 14px; font-family: inherit; background: var(--color-surface);
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.field textarea { min-height: 100px; resize: vertical; }
.field__errors { color: var(--color-danger); font-size: 13px; margin-top: 4px; list-style: none; }
.form-actions { margin-top: 24px; display: flex; gap: 12px; }

/* ===== Messages ===== */
.messages { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.message {
  padding: 12px 16px; border-radius: 6px; font-size: 14px;
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af;
}
.message--error   { background: #fef2f2; border-color: #fecaca; color: var(--color-danger); }
.message--success { background: #f0fdf4; border-color: #bbf7d0; color: var(--color-success); }
.message--warning { background: #fffbeb; border-color: #fde68a; color: var(--color-warning); }

/* ===== Quick links ===== */
.quick-links { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.quick-links a { font-weight: 500; }

/* ===== Login page ===== */
.login-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #f0f0ff 0%, #f8f9fb 60%);
}
.login-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: 12px; padding: 48px 40px; width: 100%; max-width: 400px;
  text-align: center; box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.login-card__title { font-size: 28px; font-weight: 800; color: var(--color-primary); margin-bottom: 8px; }
.login-card__subtitle { color: var(--color-text-muted); margin-bottom: 32px; font-size: 15px; }
.login-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0; color: var(--color-text-muted); font-size: 13px;
}
.login-divider::before, .login-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--color-border);
}

/* ===== Form extras ===== */
.field__hint { font-size: 13px; color: var(--color-text-muted); margin-top: 4px; }

.radio-group { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.radio-option {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--color-border); border-radius: 8px;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.radio-option:has(input:checked) {
  border-color: var(--color-primary); background: #f5f4ff;
}
.radio-option input[type="radio"] { margin-top: 2px; accent-color: var(--color-primary); }
.radio-option span { font-size: 14px; line-height: 1.5; }

.field-group-heading {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--color-text-muted); padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border); margin-bottom: 16px; margin-top: 24px;
}
.auth-badge {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px;
  background: #e0f2fe; color: #0369a1;
}
.auth-badge--local { background: #ede9fe; color: #7c3aed; }

/* ===== Search bar ===== */
.search-form__row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.search-form__row input[type="text"],
.search-form__row select {
  padding: 9px 12px; border: 1px solid var(--color-border); border-radius: 6px;
  font-size: 14px; font-family: inherit; background: var(--color-surface);
  height: 38px;
}
.search-form__row input[type="text"] { min-width: 220px; flex: 1; }
.search-form__row select { min-width: 130px; }

/* ===== Mission cards ===== */
.mission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.mission-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
  transition: box-shadow .15s, border-color .15s;
}
.mission-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  border-color: #c7c8f8;
}
.mission-card__header {
  display: flex; align-items: center; justify-content: space-between;
}
.mission-card__meta {
  font-size: 12px; color: var(--color-text-muted); font-weight: 500;
}
.mission-card__tags {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.mission-card__title {
  font-size: 16px; font-weight: 600; line-height: 1.3; margin: 0;
}
.mission-card__title a {
  color: var(--color-text); text-decoration: none;
}
.mission-card__title a:hover { color: var(--color-primary); }
.mission-card__problem {
  font-size: 13px; color: var(--color-text-muted); line-height: 1.5;
  flex: 1;
}
.mission-card__footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 10px; border-top: 1px solid var(--color-border); margin-top: auto;
}
.mission-card__actions {
  display: flex; align-items: center; gap: 10px;
}
.mission-card__assignment-count {
  font-size: 12px; font-weight: 600; color: var(--color-primary);
  background: #ede9fe; border-radius: 999px; padding: 2px 10px;
}
.badge--type { background: #f0f0ff; color: var(--color-primary); }
.btn--sm { padding: 5px 12px; font-size: 13px; }
.btn-link--danger { color: var(--color-danger); }

/* ===== Detail grid (legacy) ===== */
.detail-grid {
  display: grid; grid-template-columns: 160px 1fr; gap: 12px 24px; align-items: start;
}
.detail-grid dt { font-weight: 600; font-size: 13px; color: var(--color-text-muted); padding-top: 2px; }
.detail-grid dd { font-size: 14px; }
.detail-grid__wide { grid-column: 2; white-space: pre-wrap; }

/* ===== Buttons extra ===== */
.btn--danger { background: #fee2e2; color: var(--color-danger); border: 1px solid #fca5a5; }
.btn--danger:hover { background: #fecaca; text-decoration: none; }
.back-link { font-size: 14px; color: var(--color-text-muted); font-weight: 500; }
.back-link:hover { color: var(--color-primary); text-decoration: none; }

/* ===== Section cards ===== */
.section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.section-card__heading {
  font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--color-text-muted); padding: 12px 20px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}
.section-card__body {
  padding: 20px; font-size: 14px; line-height: 1.7; white-space: pre-wrap;
  color: var(--color-text);
}

/* ===== Info list (sidebar) ===== */
.info-list { list-style: none; }
.info-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 20px; font-size: 13px;
}
.info-list li + li { border-top: 1px solid var(--color-border); }
.info-list__label { color: var(--color-text-muted); font-weight: 500; }
.info-list__value { font-weight: 600; text-align: right; }

/* ===== Mission detail layout ===== */
.mission-detail__title {
  font-size: 26px; font-weight: 800; margin-bottom: 20px; line-height: 1.2;
}
.mission-detail__layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}
.mission-detail__main { display: flex; flex-direction: column; gap: 16px; }
.mission-detail__sidebar { position: sticky; top: calc(var(--nav-height) + 16px); }

@media (max-width: 720px) {
  .mission-detail__layout { grid-template-columns: 1fr; }
  .mission-detail__sidebar { position: static; }
  .mission-grid { grid-template-columns: 1fr; }
}

/* ===== Attachments ===== */
.att-list { list-style: none; }
.att-list__row {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 20px; font-size: 13px;
}
.att-list__row + .att-list__row { border-top: 1px solid var(--color-border); }
.att-list__icon {
  width: 12px; height: 12px; flex-shrink: 0; color: var(--color-text-muted); opacity: .6;
}
.att-list__name { flex: 1; font-weight: 500; color: var(--color-primary); }
.att-list__name:hover { text-decoration: underline; }
.att-list__ext { flex-shrink: 0; }
.att-list__del { font-size: 12px; }

.att-upload-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 11px 20px; border-top: 1px solid var(--color-border);
}
.att-upload-filename {
  font-size: 13px; font-weight: 500; color: var(--color-text);
  flex-shrink: 0; max-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.att-upload-label {
  flex: 1; min-width: 120px; padding: 5px 10px;
  border: 1px solid var(--color-border); border-radius: 6px;
  font-size: 13px; font-family: inherit; background: var(--color-surface);
}
.att-upload-label:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }

/* Generic input */
.input {
  background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 8px 12px; font-size: 14px; color: var(--color-text); outline: none; width: 100%;
}
.input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.input--sm { padding: 6px 10px; font-size: 13px; }
