:root {
  --navy: #091724;
  --navy-2: #10283d;
  --orange: #f36b21;
  --orange-dark: #cf5013;
  --ink: #152331;
  --muted: #6b7b8c;
  --canvas: #edf2f6;
  --panel: #ffffff;
  --line: #d9e2ea;
  --blue: #1976d2;
  --green: #16865c;
  --red: #c43d48;
  --warning: #d77817;
  --shadow: 0 12px 32px rgba(10, 29, 45, .08);
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.topbar {
  height: 68px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between;
  color: #fff; background: linear-gradient(120deg, #07131e, #112d43); border-bottom: 3px solid var(--orange);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 900; letter-spacing: .08em; }
.brand b { color: var(--orange); }
.mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; color: #fff; background: var(--orange); font-size: 22px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.release { padding: 6px 10px; border-radius: 7px; color: #c9d8e5; background: rgba(255,255,255,.07); font-size: 12px; font-weight: 800; }

.auth-shell { min-height: calc(100vh - 68px); display: grid; place-items: center; padding: 32px 16px; background: radial-gradient(circle at 10% 10%, #fff, transparent 36%), linear-gradient(140deg, #e7eef4, #f8fafc); }
.auth-card { width: min(920px, 100%); display: grid; grid-template-columns: 1.1fr .9fr; gap: 42px; padding: 42px; background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 6px 0 14px; font-size: clamp(30px, 4vw, 48px); line-height: 1.03; letter-spacing: -.04em; }
.secret-box { padding: 16px; border-radius: 12px; background: #f1f6fa; border: 1px solid var(--line); overflow-wrap: anywhere; }
.secret-box span, .secret-box code, .secret-box small { display: block; }
.secret-box code { margin: 8px 0; padding: 8px; background: #fff; border-radius: 7px; font-size: 16px; font-weight: 800; }

.app-shell { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { padding: 18px 14px; color: #d9e5ef; background: var(--navy); }
.identity-card { margin-bottom: 16px; padding: 14px; border: 1px solid rgba(255,255,255,.09); border-radius: 12px; background: rgba(255,255,255,.04); }
.identity-card strong, .identity-card span { display: block; }
.identity-card span { margin-top: 4px; color: #8fa6ba; font-size: 12px; }
.nav-item { width: 100%; margin: 3px 0; padding: 11px 12px; color: #c9d8e4; background: transparent; border: 0; border-left: 3px solid transparent; border-radius: 7px; text-align: left; font-weight: 700; }
.nav-item:hover, .nav-item.active { color: #fff; background: #183349; border-left-color: var(--orange); }
.workspace { min-width: 0; padding: 26px; }
.page { display: none; max-width: 1550px; margin: 0 auto; }
.page.active { display: block; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 18px; }
.page-head h1 { margin: 2px 0 0; font-size: 30px; letter-spacing: -.025em; }
.eyebrow { margin: 0; color: var(--orange-dark); font-size: 11px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.muted, .optional { color: var(--muted); }
.optional { font-size: 12px; font-weight: 500; }

.panel { margin-bottom: 16px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 4px 14px rgba(13,35,54,.035); }
.panel h2 { margin: 0 0 16px; font-size: 18px; }
.panel h3 { margin: 22px 0 10px; font-size: 14px; }
.panel-head { min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 16px; }
.metric { min-height: 116px; position: relative; overflow: hidden; padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 4px 14px rgba(13,35,54,.035); }
.metric span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.metric strong { display: block; margin-top: 10px; font-size: 30px; }
.metric i { position: absolute; right: -9px; bottom: -9px; width: 45px; height: 45px; border-radius: 50%; opacity: .16; }
.tone-blue { background: var(--blue); } .tone-green { background: var(--green); } .tone-red { background: var(--red); } .tone-orange { background: var(--orange); } .tone-white { background: #8294a5; }
.split { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.action-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; }
.summary-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
.summary-grid div { padding: 12px; border-radius: 9px; background: #f5f8fa; }
.summary-grid span, .summary-grid strong { display: block; }
.summary-grid span { color: var(--muted); font-size: 11px; }
.summary-grid strong { margin-top: 4px; }

label { display: block; color: #34495b; font-size: 12px; font-weight: 750; }
input, select, textarea { width: 100%; margin: 5px 0 11px; padding: 10px 11px; color: var(--ink); background: #fff; border: 1px solid #cbd6df; border-radius: 8px; outline: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(243,107,33,.12); }
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.check input { width: auto; margin: 0; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; align-items: end; }
.form-action { margin-bottom: 11px; }
.form-message { min-height: 18px; margin: 8px 0 0; color: var(--red); font-size: 13px; font-weight: 700; }

.btn { min-height: 38px; padding: 8px 13px; border: 1px solid transparent; border-radius: 8px; font-size: 12px; font-weight: 850; }
.btn.primary { color: #fff; background: var(--orange); }
.btn.primary:hover { background: var(--orange-dark); }
.btn.success { color: #fff; background: var(--green); }
.btn.subtle { color: #28445b; background: #eef3f7; border-color: #d9e2ea; }
.btn.danger { color: #fff; background: var(--red); }
.btn.wide { width: 100%; }

.pill { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 9px; border-radius: 99px; font-size: 11px; font-weight: 800; }
.pill.neutral { color: #546777; background: #eaf0f4; }
.pill.blue { color: #0d5fb1; background: #e1f0ff; }
.pill.green { color: #0e7049; background: #ddf5e9; }
.pill.orange, .pill.warning { color: #a44d09; background: #fff0dc; }
.pill.red { color: #a52b35; background: #fde4e7; }
.pill.white { color: #596b79; background: #fff; border: 1px solid var(--line); }
.counter { min-width: 28px; padding: 4px 8px; border-radius: 99px; color: #fff; background: var(--navy-2); text-align: center; font-size: 11px; font-weight: 800; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; padding: 5px; background: #dfe7ed; border-radius: 10px; overflow-x: auto; }
.tab { padding: 9px 13px; white-space: nowrap; border: 0; border-radius: 7px; color: #4c6173; background: transparent; font-size: 12px; font-weight: 800; }
.tab.active { color: #fff; background: var(--navy-2); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.table-panel { overflow: hidden; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 10px; color: #607283; background: #f5f8fa; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid #e6edf2; vertical-align: top; }
tbody tr:hover { background: #fafcfd; }
.empty-row td { padding: 24px; color: var(--muted); text-align: center; }
.list-state { color: var(--muted); font-size: 13px; }
.list-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #e7edf2; }
.list-item:last-child { border-bottom: 0; }
.list-item strong, .list-item span { display: block; }
.list-item span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.document-list { display: flex; flex-wrap: wrap; gap: 8px; }
.document-chip { padding: 8px 10px; color: #244d6c; background: #eef5fa; border: 1px solid #d7e5ef; border-radius: 8px; text-decoration: none; font-size: 11px; font-weight: 750; }
.confidentiality-banner { color: #71323a; background: #fff7f7; border-left: 4px solid var(--red); font-size: 13px; }
.mission-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; }
.mission-card { min-width: 0; }
.mission-card .mission-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.mission-card .mission-meta div { padding: 9px; border-radius: 8px; background: #f5f8fa; }
.mission-card .mission-meta span, .mission-card .mission-meta strong { display: block; overflow-wrap: anywhere; }
.mission-card .mission-meta span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.mission-card .mission-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.toast { position: fixed; top: 82px; right: 24px; z-index: 80; max-width: 420px; padding: 12px 16px; color: #fff; background: var(--navy-2); border-left: 4px solid var(--green); border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; font-weight: 700; }
.toast.error { border-left-color: var(--red); }

.record-actions, .record-activity-list { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.activity-open { min-height: 32px; padding: 6px 9px; }
.activity-backdrop { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: flex-end; background: rgba(4, 16, 27, .52); }
.activity-drawer { width: min(720px, 100vw); height: 100%; display: flex; flex-direction: column; color: var(--ink); background: #f6f9fb; box-shadow: -18px 0 46px rgba(3, 18, 30, .24); }
.activity-head { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.activity-head h2 { margin: 4px 0 0; font-size: 20px; }
.activity-head-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.activity-content { min-height: 0; flex: 1; padding: 18px 20px 28px; overflow-y: auto; }
.activity-compose-card { margin-bottom: 18px; padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.activity-compose-card h3 { margin: 0 0 5px; }
.activity-compose-card p { margin: 0 0 14px; font-size: 12px; }
.activity-tabs { position: sticky; top: -18px; z-index: 3; display: flex; gap: 5px; margin: -18px -20px 16px; padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line); overflow-x: auto; }
.activity-tab { padding: 8px 10px; color: #536879; background: transparent; border: 0; border-radius: 7px; white-space: nowrap; font-size: 11px; font-weight: 850; }
.activity-tab.active { color: #fff; background: var(--navy-2); }
.activity-panel { display: none; }
.activity-panel.active { display: block; }
.activity-list { display: grid; gap: 10px; }
.activity-thread-card, .activity-message, .activity-event-card { padding: 13px 14px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 11px; }
.activity-thread-card { width: 100%; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; text-align: left; }
.activity-thread-card:hover { border-color: #aebfcd; box-shadow: 0 5px 14px rgba(13,35,54,.06); }
.activity-thread-card strong, .activity-thread-card span { display: block; }
.activity-thread-card span, .activity-meta, .activity-event-card span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.activity-thread-main { min-width: 0; }
.activity-thread-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-message { border-left: 4px solid #c7d4de; }
.activity-message.high { border-left-color: var(--warning); }
.activity-message.critical { border-left-color: var(--red); }
.activity-message-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.activity-message-body { margin: 11px 0; color: #263949; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.activity-message-links, .activity-message-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.activity-message-form { margin-top: 14px; padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.activity-empty { padding: 24px 14px; text-align: center; background: #fff; border: 1px dashed #becbd6; border-radius: 11px; }
body.activity-drawer-open { overflow: hidden; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .action-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .form-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .mission-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 68px; z-index: 35; padding: 8px; overflow-x: auto; }
  .identity-card { display: none; }
  .sidebar nav { display: flex; gap: 4px; }
  .nav-item { min-width: max-content; border-left: 0; border-bottom: 3px solid transparent; }
  .nav-item:hover, .nav-item.active { border-left-color: transparent; border-bottom-color: var(--orange); }
  .workspace { padding: 16px; }
  .auth-card { grid-template-columns: 1fr; gap: 22px; padding: 28px; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .topbar { padding: 0 12px; }
  .brand { font-size: 14px; }
  .release { display: none; }
  .metric-grid, .action-grid, .form-grid, .summary-grid, .mission-grid { grid-template-columns: 1fr; }
  .page-head { align-items: center; }
  .page-head h1 { font-size: 24px; }
  .top-actions { gap: 5px; }
  #communicationInboxBtn { max-width: 142px; padding: 6px 8px; }
  .activity-head { align-items: flex-start; padding: 13px; }
  .activity-head-actions { flex-direction: column; }
  .activity-content { padding: 14px 13px 24px; }
  .activity-tabs { top: -14px; margin: -14px -13px 14px; padding: 10px 13px; }
  .activity-message-form .two-cols, .activity-compose-card .two-cols { grid-template-columns: 1fr; gap: 0; }
}
