:root {
  color-scheme: light;
  --navy: #0b5577;
  --navy-strong: #073f61;
  --teal: #22bfc0;
  --coral: #f45b5f;
  --ink: #17324b;
  --muted: #66798c;
  --line: #d8e3e9;
  --surface: #f4f8fa;
  --panel: #ffffff;
  --soft-blue: #eaf7fa;
  --soft-green: #e8f7ee;
  --soft-amber: #fff3d8;
  --soft-red: #ffebea;
  --shadow: 0 8px 24px rgba(14, 61, 84, 0.09);
  font-family: Inter, Lato, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body, #root { min-height: 100%; margin: 0; }
body { background: var(--surface); color: var(--ink); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
a { color: inherit; }

.boot-message,
.page-loader {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.icon {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}
.icon-host { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.icon-host .icon { display: block; }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(380px, 1.15fr);
  background: var(--panel);
}

.login-brand {
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--soft-blue);
  color: var(--navy-strong);
}

.brand-logo { display: block; object-fit: contain; object-position: left center; }
.login-logo { width: min(280px, 85%); height: auto; }
.login-brand-copy { max-width: 440px; }
.login-brand-copy h1 { margin: 0 0 12px; font-size: 34px; letter-spacing: 0; }
.login-brand-copy p { margin: 0; color: #496b7d; font-size: 17px; line-height: 1.55; }
.login-brand small { color: var(--muted); }

.login-main { display: grid; place-items: center; padding: 32px; }
.login-form { width: min(440px, 100%); }
.login-form h2 { margin: 0 0 8px; color: var(--navy-strong); font-size: 28px; }
.login-form > p { margin: 0 0 28px; color: var(--muted); }

.field { display: grid; gap: 7px; min-width: 0; }
.field + .field { margin-top: 16px; }
.field label, .field-label { color: var(--ink); font-weight: 700; font-size: 13px; }
.field input,
.field select,
.field textarea,
.filter-field input,
.filter-field select {
  width: 100%;
  min-height: 43px;
  border: 1px solid #becfd8;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus,
.filter-field input:focus,
.filter-field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(34, 191, 192, 0.14);
}
.password-wrap { position: relative; }
.password-wrap input { padding-right: 44px; }
.password-toggle {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.alert {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 16px 0;
  padding: 11px 12px;
  border: 1px solid #f2b7b9;
  border-radius: 6px;
  background: var(--soft-red);
  color: #9c3034;
  font-size: 14px;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button,
.nav-button,
.tab-button,
.status-button {
  border-radius: 6px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 14px;
  font-weight: 700;
  white-space: nowrap;
}
.primary-button { background: var(--navy); color: #fff; }
.primary-button:hover { background: var(--navy-strong); }
.secondary-button { background: #fff; color: var(--navy); border-color: #b7cbd5; }
.secondary-button:hover { background: var(--soft-blue); }
.danger-button { background: #fff; color: #b33a3e; border-color: #efb7b9; }
.danger-button:hover { background: var(--soft-red); }
.login-submit { width: 100%; min-height: 48px; margin-top: 22px; }
.icon-button { width: 38px; min-width: 38px; padding: 0; background: #fff; color: var(--navy); border-color: var(--line); }
.icon-button.danger { color: #b33a3e; }
.button-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 24px 16px 16px;
  z-index: 10;
}
.sidebar-brand { padding: 0 10px 24px; }
.sidebar-logo { width: 174px; max-width: 100%; height: auto; }
.sidebar-brand span { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.side-nav { display: grid; gap: 6px; }
.nav-button {
  width: 100%;
  justify-content: flex-start;
  min-height: 46px;
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
.nav-button:hover { background: var(--surface); color: var(--navy); }
.nav-button.active { background: var(--soft-blue); color: var(--navy); }
.sidebar-user { margin-top: auto; padding: 16px 10px 12px; border-top: 1px solid var(--line); }
.sidebar-user strong, .sidebar-user span { display: block; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user span { color: var(--muted); font-size: 13px; margin-top: 3px; }
.signout-button { margin-top: 10px; width: 100%; }

.content { min-width: 0; }
.topbar {
  height: 72px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}
.topbar h1 { margin: 0; color: var(--navy-strong); font-size: 21px; }
.topbar-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.admin-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.page { padding: 26px 28px 40px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.page-header h2 { margin: 0 0 5px; color: var(--navy-strong); font-size: 24px; }
.page-header p { margin: 0; color: var(--muted); line-height: 1.45; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab-button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; color: var(--muted); }
.tab-button.active { color: var(--navy); border-bottom-color: var(--teal); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.toolbar-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.search-wrap { position: relative; width: min(360px, 100%); }
.search-wrap > .icon-host { position: absolute; left: 12px; top: 12px; color: var(--muted); }
.search-wrap input { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px 9px 38px; outline: none; }
.search-wrap input:focus { border-color: var(--teal); }
.toolbar-select { min-width: 190px; min-height: 42px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); padding: 9px 34px 9px 12px; }

.table-shell { background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.data-table th { background: #edf5f8; color: #486578; text-align: left; font-size: 12px; text-transform: uppercase; padding: 12px 14px; }
.data-table td { padding: 14px; border-top: 1px solid #e6edf1; vertical-align: top; overflow-wrap: anywhere; }
.data-table tbody tr:hover { background: #f9fcfd; }
.data-table tbody tr.selected { background: var(--soft-blue); }
.cell-title { font-weight: 800; color: var(--navy-strong); }
.cell-subtitle { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; }
.empty-state { text-align: center; padding: 52px 20px; color: var(--muted); }
.empty-state > .icon-host { color: var(--navy); margin-bottom: 8px; }

.badge, .team-chip, .recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 16px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.badge.active, .badge.closed { background: var(--soft-green); color: #167446; }
.badge.inactive, .badge.rejected { background: var(--soft-red); color: #a83b40; }
.badge.new { background: var(--soft-blue); color: var(--navy); }
.badge.in-progress { background: var(--soft-amber); color: #9a6200; }
.team-chip, .recipient-chip { background: #eef3f6; color: #526b7d; margin: 2px 4px 2px 0; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 35, 48, 0.48);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
}
.modal {
  width: min(650px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(4, 37, 54, 0.24);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-header h3 { margin: 0; color: var(--navy-strong); font-size: 19px; }
.modal-body { padding: 20px; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.modal-grid .span-2 { grid-column: span 2; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); }
.checkbox-line { display: flex; align-items: center; gap: 9px; min-height: 42px; }
.checkbox-line input { width: 18px; height: 18px; accent-color: var(--navy); }
.select-with-action { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.compact-button { min-height: 43px; padding: 9px 12px; }
.inline-team-create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft-blue);
}
.field-error { color: #9c3034; font-size: 12px; font-weight: 700; }
.icon-select { position: relative; }
.icon-select-trigger {
  width: 100%;
  min-height: 43px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  text-align: left;
}
.icon-select-value { display: inline-flex; align-items: center; gap: 9px; min-width: 0; font-weight: 700; }
.icon-select-menu {
  position: absolute;
  z-index: 12;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(4, 37, 54, 0.16);
}
.icon-select-option {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  text-align: left;
}
.icon-select-option > .icon-host:last-child { margin-left: auto; }
.icon-select-option:hover, .icon-select-option.selected { background: var(--soft-blue); color: var(--navy); }
.multi-select { position: relative; }
.multi-select-trigger {
  width: 100%;
  min-height: 43px;
  border: 1px solid #becfd8;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}
.multi-select-trigger > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi-select-menu {
  position: absolute;
  z-index: 12;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(4, 37, 54, 0.16);
}
.multi-select-option { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 4px; color: var(--ink); cursor: pointer; }
.multi-select-option:hover, .multi-select-option.selected { background: var(--soft-blue); }
.multi-select-option input { width: 18px; height: 18px; min-height: 0; padding: 0; border: 0; accent-color: var(--navy); }
.team-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.team-option { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; color: var(--ink); }
.team-option.selected { border-color: var(--teal); background: var(--soft-blue); }

.filters {
  display: grid;
  grid-template-columns: minmax(190px, 1.4fr) minmax(150px, 0.8fr) minmax(140px, 0.7fr) minmax(140px, 0.7fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 16px;
}
.filter-field { display: grid; gap: 6px; min-width: 0; }
.filter-field label { color: var(--muted); font-weight: 700; font-size: 12px; }
.filter-actions { display: flex; gap: 8px; }
.task-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.summary-item { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--navy); padding: 12px 14px; border-radius: 6px; }
.summary-item strong { display: block; color: var(--navy-strong); font-size: 22px; }
.summary-item span { color: var(--muted); font-size: 12px; }
.task-table-area { min-width: 0; }
.task-row { cursor: pointer; }
.task-table-shell .data-table td:last-child { white-space: nowrap; overflow: visible; }
.task-preview-modal {
  width: min(860px, 100%);
  max-height: calc(100vh - 40px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(4, 37, 54, 0.24);
  overflow: hidden;
}
.detail-header { padding: 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
.detail-header h3 { margin: 0 0 4px; color: var(--navy-strong); font-size: 18px; }
.detail-header p { margin: 0; color: var(--muted); font-size: 13px; }
.detail-body { padding: 18px; max-height: calc(100vh - 190px); overflow: auto; }
.detail-section + .detail-section { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 18px; }
.detail-section h4 { margin: 0 0 10px; color: var(--navy-strong); font-size: 14px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-label { color: var(--muted); font-size: 12px; }
.detail-value { margin-top: 3px; color: var(--ink); font-weight: 700; overflow-wrap: anywhere; }
.description-box { margin: 0; line-height: 1.5; white-space: pre-wrap; color: #425a6b; }
.status-controls { display: flex; flex-wrap: wrap; gap: 7px; }
.status-button { min-height: 34px; padding: 6px 9px; background: #fff; border-color: var(--line); color: var(--muted); white-space: nowrap; }
.status-button.active { border-color: var(--teal); color: var(--navy); background: var(--soft-blue); }
.comment-list { display: grid; gap: 10px; }
.comment { border-left: 3px solid var(--teal); padding-left: 10px; }
.comment p { margin: 0 0 4px; line-height: 1.4; white-space: pre-wrap; }
.comment small { color: var(--muted); }
.comment-form { margin-top: 12px; }
.comment-form textarea { width: 100%; min-height: 76px; resize: vertical; border: 1px solid #becfd8; border-radius: 6px; padding: 10px; }
.comment-form .primary-button { margin-top: 8px; width: 100%; }
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  background: var(--navy-strong);
  color: #fff;
  border-radius: 6px;
  padding: 12px 15px;
  box-shadow: var(--shadow);
  z-index: 200;
}

@media (max-width: 1120px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filter-actions { grid-column: span 2; justify-content: flex-end; }
}

@media (max-width: 820px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 230px; padding: 28px; }
  .login-brand-copy h1 { font-size: 26px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-brand { padding: 2px 8px 12px; }
  .sidebar-logo { width: 150px; }
  .side-nav { grid-template-columns: 1fr 1fr; }
  .sidebar-user { display: none; }
  .topbar { height: 62px; padding: 0 16px; }
  .page { padding: 20px 16px 34px; }
  .topbar-meta span { display: none; }
  .modal-grid { grid-template-columns: 1fr; }
  .modal-grid .span-2 { grid-column: auto; }
  .task-summary { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .login-main { padding: 28px 20px; }
  .page-header, .toolbar { align-items: stretch; flex-direction: column; }
  .page-header .primary-button, .toolbar .primary-button { width: 100%; }
  .toolbar-main { flex-direction: column; align-items: stretch; }
  .search-wrap { width: 100%; }
  .toolbar-select { width: 100%; }
  .filters { grid-template-columns: 1fr; }
  .filter-actions { grid-column: auto; }
  .filter-actions > * { flex: 1; }
  .select-with-action, .inline-team-create { grid-template-columns: 1fr; }
  .select-with-action .compact-button, .inline-team-create .compact-button { width: 100%; }
  .table-shell { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .data-table, .data-table tbody { display: block; }
  .data-table thead { display: none; }
  .data-table tr { display: block; background: #fff; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; box-shadow: var(--shadow); }
  .data-table td { display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid #edf1f3; padding: 11px 12px; }
  .data-table td:first-child { border-top: 0; }
  .data-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 700; flex: 0 0 92px; }
  .data-table td > * { text-align: right; }
  .row-actions { justify-content: flex-end; }
  .detail-grid { grid-template-columns: 1fr; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer button { width: 100%; }
}
