/* Brobsmarine cockpit — unified design system */
:root {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --border: #e4e7ec;
  --text: #1a202c;
  --text-2: #667085;
  --brand: #14243d;        /* deep navy */
  --brand-2: #1d3557;
  --accent: #0e7490;       /* teal for actions */
  --accent-hover: #155e75;
  --good-bg: #e7f6ee; --good-fg: #17714a;
  --warn-bg: #fdf3e0; --warn-fg: #9a6700;
  --bad-bg:  #fdebe9; --bad-fg:  #b42318;
  --info-bg: #eaf2fd; --info-fg: #1d4ed8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  overflow-x: hidden;
}

/* ---------- header / nav ---------- */
.dashboard-header {
  background: var(--brand);
  color: #fff;
  padding: 0;
  margin-bottom: 20px;
  position: sticky; top: 0; z-index: 50;
}
.header-content {
  max-width: 1400px; margin: 0 auto;
  padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
.header-content h1 {
  font-size: 16px; font-weight: 650; letter-spacing: .2px;
  color: #fff; white-space: nowrap;
}
.header-actions { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }

/* nav */
.nav-link {
  position: relative;
  color: rgba(255,255,255,.68); text-decoration: none;
  font-size: 13px; font-weight: 500;
  padding: 8px 12px; border-radius: 8px;
  transition: color .15s, background .15s;
  display: inline-flex; align-items: center;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-link.active { color: #fff; font-weight: 650; }
.nav-link.active::after {
  content: ''; position: absolute; left: 12px; right: 12px; bottom: 3px;
  height: 2px; border-radius: 2px; background: #2fb6d9;
}
.nav-sep { width: 1px; height: 18px; background: rgba(255,255,255,.18); margin: 0 8px; }
.user-menu { position: relative; }
.avatar-btn { background: none; border: none; padding: 2px; cursor: pointer;
              display: flex; align-items: center; gap: 5px; color: rgba(255,255,255,.65); }
.avatar-btn::after { content: '▾'; font-size: 10px; transition: color .15s; }
.avatar-btn:hover { color: #fff; }
.avatar-btn:hover .avatar { box-shadow: 0 0 0 3px rgba(255,255,255,.2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #2fb6d9, #0e7490);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  border: 2px solid rgba(255,255,255,.28); box-sizing: border-box;
  transition: box-shadow .15s;
}
.user-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 10px);
  background: #fff; border-radius: 12px; min-width: 210px; padding: 6px;
  box-shadow: 0 12px 34px rgba(16,24,40,.22); z-index: 200;
}
.user-dropdown.open { display: block; }
.ud-name { padding: 9px 12px 8px; font-size: 12px; font-weight: 650; color: #667085;
           border-bottom: 1px solid #eef1f5; margin-bottom: 4px; }
.ud-item { display: block; padding: 9px 12px; border-radius: 8px; color: #14243d;
           text-decoration: none; font-size: 13px; }
.ud-item:hover { background: #f2f4f7; }
.ud-item.active { background: #eef7f9; color: #0e7490; font-weight: 600; }
.ud-sep { height: 1px; background: #eef1f5; margin: 4px 0; }
.ud-logout { color: #b42318; }
.nav-logout { color: rgba(255,255,255,.45); margin-left: 2px; }
.nav-logout:hover { color: #fff; background: rgba(255,255,255,.07); }
.logout-btn {
  color: #fff; text-decoration: none; font-size: 13px; font-weight: 500;
  padding: 7px 12px; border-radius: 8px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  transition: background .15s;
  min-height: 34px; display: inline-flex; align-items: center;
}
.logout-btn:hover, .logout-btn.active { background: rgba(255,255,255,.22); }

/* ---------- layout ---------- */
.dashboard-main { max-width: 1400px; margin: 0 auto; padding: 0 16px 48px; }
.dashboard-section, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-top: 16px;
}
.dashboard-section h2, .panel h2 { font-size: 15px; font-weight: 650; margin-bottom: 2px; }
.dashboard-section h3, .panel h3 { font-size: 14px; font-weight: 650; margin: 4px 0 8px; }
.sub, .section-note { font-size: 12px; color: var(--text-2); margin-bottom: 12px; }
.muted { color: var(--text-2); font-size: 12px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 0; }
.two-col > .panel, .two-col > div { min-width: 0; }
.dashboard-section, .panel { min-width: 0; max-width: 100%; }

/* ---------- KPI cards ---------- */
.kpis, .stats-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 8px 0 4px; }
.kpi, .stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi .val { font-size: 24px; font-weight: 750; font-variant-numeric: tabular-nums; }
.kpi .lbl { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: .4px; margin-top: 2px; }
.kpi.accent .val { color: var(--warn-fg); }
.kpi.good .val { color: var(--good-fg); }
.stat-card strong { display: block; font-size: 12px; color: var(--text-2); font-weight: 600; margin-bottom: 4px; }
.stat-card span { font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; }

/* ---------- filters & controls ---------- */
.filterbar, .filters, .refresh-controls {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: end;
  margin: 10px 0;
}
.filterbar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin-top: 16px; }
.filterbar label { display: block; font-size: 10.5px; color: var(--text-2); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; }
input[type="text"], input[type="date"], input[type="number"], select {
  padding: 9px 12px; border: 1px solid #d0d5dd; border-radius: 8px;
  font-size: 14px; background: #fff; color: var(--text);
  min-height: 40px; max-width: 100%;
}
input:focus, select:focus { outline: 2px solid rgba(14,116,144,.25); border-color: var(--accent); }
.btn, .refresh-btn, .submit-maem-btn, .login-btn {
  padding: 9px 16px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer;
  min-height: 40px;
  transition: background .15s;
}
.btn:hover, .refresh-btn:hover, .submit-maem-btn:hover, .login-btn:hover { background: var(--accent-hover); }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid #d0d5dd; }
.btn.ghost:hover { background: var(--bg); }
.submit-maem-btn { padding: 7px 12px; font-size: 12px; min-height: 34px; }
.submit-maem-btn:disabled { background: #cbd5e1; cursor: not-allowed; }

/* ---------- tables ---------- */
.table-container, .scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
}
.scroll { max-height: 440px; overflow-y: auto; }
table.data-table, table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
.data-table th, .tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--text-2); font-weight: 600;
  padding: 9px 10px; border-bottom: 2px solid var(--border);
  white-space: nowrap; background: var(--surface);
  position: sticky; top: 0;
}
.data-table td, .tbl td { padding: 9px 10px; border-bottom: 1px solid #eef0f3; vertical-align: top; }
.data-table tr:hover td, .tbl tr:hover td { background: #f8fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.loading, .error { padding: 14px; color: var(--text-2); }
.error { color: var(--bad-fg); }
.good { color: var(--good-fg); font-weight: 600; }
.bad, .danger { color: var(--bad-fg); font-weight: 600; }
.net { font-weight: 650; color: var(--good-fg); }
.warn-row td { background: #fffaf0; }

/* ---------- badges / status pills ---------- */
.tag, .push-badge, .maem-status {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: #eef0f3; color: #475467;
}
.tag.open { background: var(--warn-bg); color: var(--warn-fg); }
.tag.won { background: var(--good-bg); color: var(--good-fg); }
.tag.lost { background: var(--bad-bg); color: var(--bad-fg); }
.push-updated, .push-created { background: var(--good-bg); color: var(--good-fg); }
.push-pending { background: var(--warn-bg); color: var(--warn-fg); }
.push-skipped_no_item { background: var(--warn-bg); color: var(--warn-fg); }
.push-error { background: var(--bad-bg); color: var(--bad-fg); }
.status-not_in_maem { background: #eef0f3; color: #475467; }
.status-pending_maem { background: var(--warn-bg); color: var(--warn-fg); }
.status-submitted_maem { background: var(--info-bg); color: var(--info-fg); }
.status-quoted_maem, .status-completed { background: var(--good-bg); color: var(--good-fg); }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: #eef0f3; margin: 2px 4px 2px 0; font-size: 12px; }

/* ---------- login ---------- */
.login-body {
  display: flex; justify-content: center; align-items: center;
  min-height: 100vh; background: var(--brand); padding: 16px;
}
.login-container {
  background: #fff; padding: 28px; border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
  width: 100%; max-width: 380px;
}
.login-wrap { display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 380px; }
.login-logo { width: 210px; height: auto; margin-bottom: 26px; }
.login-header { text-align: center; margin-bottom: 20px; }
.login-header p { color: var(--text-2); font-size: 13px; }
.login-form .form-group { margin-bottom: 14px; }
.login-form label { display: block; margin-bottom: 5px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.login-form input {
  width: 100%; box-sizing: border-box; height: 42px; padding: 0 12px;
  border: 1px solid #d0d5dd; border-radius: 8px; font-size: 14px;
  font-family: inherit; color: var(--text); background: #fff;
}
.login-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,116,144,.14); }
.login-btn { width: 100%; }
#error-message, #locked-message { color: var(--bad-fg); text-align: center; margin-top: 12px; padding: 8px; background: var(--bad-bg); border-radius: 8px; font-size: 13px; }

/* ---------- mobile ---------- */
@media (max-width: 1050px) {
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 14px; }
  .header-content { padding: 8px 12px; }
  .header-content h1 { font-size: 14px; width: 100%; }
  .header-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .nav-link { padding: 7px 9px; font-size: 12.5px; }
  .user-dropdown { position: fixed; left: 10px; right: 10px; top: auto; margin-top: 8px; }
  .dashboard-main { padding: 0 10px 40px; }
  .dashboard-section, .panel { padding: 14px 12px; margin-top: 12px; }
  .filterbar, .filters { gap: 8px; }
  .filterbar > div, .filters > div { flex: 1 1 45%; min-width: 130px; }
  .filterbar input, .filterbar select, .filters input, .filters select { width: 100%; min-width: 0; }
  .btn, .refresh-btn { flex: 1 1 auto; }
  .kpis, .stats-container { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi .val { font-size: 20px; }
  .data-table td, .tbl td, .data-table th, .tbl th { padding: 8px 8px; }
}

/* ---------- brand logo in page headers ---------- */
.brand-h1 h1 { display: none; }
.brand-h1 { display: flex; align-items: center; gap: 12px; min-width: 0; }
.nav-logo { height: 20px; width: auto; display: block; flex: 0 0 auto; }
@media (max-width: 640px) { .nav-logo { height: 16px; } }

/* ---------- subtle scrollbars everywhere ---------- */
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: #98a2b3; }
