*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:       #0f1e3c;
  --navy-mid:   #162a52;
  --navy-light: #1e3a6e;
  --yellow:     #e8c933;
  --yellow-dim: #c9ac1e;
  --yellow-bg:  #fdf8e1;
  --white:      #ffffff;
  --surface:    #f4f6f9;
  --border:     #e2e6ed;
  --ink:        #1a2238;
  --muted:      #64748b;
  --danger:     #dc2626;
  --danger-bg:  #fef2f2;
  --success:    #16a34a;
  --success-bg: #f0fdf4;
  --warn:       #d97706;
  --warn-bg:    #fffbeb;
  --info:       #2563eb;
  --info-bg:    #eff6ff;

  --sidebar-w:  228px;
  --topbar-h:   56px;
}

html { min-height: 100%; }
body {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  background: var(--surface);
  color: var(--ink);
  min-height: 100vh;
}

.hidden { display: none !important; }
button, input, select { font: inherit; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* ══════════════════════════════════
   LOGIN
══════════════════════════════════ */
body.login-mode {
  background: var(--navy);
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  color: var(--ink);
}

.login-left {
  width: 52%;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px 72px;
  position: relative;
  overflow: hidden;
}
.login-left::before {
  content: '';
  position: absolute;
  top: -80px;
  right: -120px;
  width: 340px;
  height: 700px;
  background: var(--yellow);
  opacity: .07;
  transform: rotate(18deg);
  pointer-events: none;
}
.login-left::after {
  content: '';
  position: absolute;
  bottom: -100px;
  left: -60px;
  width: 220px;
  height: 500px;
  background: var(--yellow);
  opacity: .04;
  transform: rotate(18deg);
  pointer-events: none;
}
.left-logo {
  width: 320px;
  max-width: 100%;
  margin-bottom: 48px;
  position: relative;
  z-index: 1;
}
.left-tagline {
  position: relative;
  z-index: 1;
}
.left-tagline h1 {
  font-size: 38px;
  font-weight: 700;
  color: var(--white);
  line-height: 1.18;
  margin-bottom: 16px;
}
.left-tagline h1 span { color: var(--yellow); }
.left-tagline p {
  font-size: 15px;
  color: rgba(255,255,255,.55);
  line-height: 1.7;
  max-width: 380px;
}
.identity-dots {
  display: flex;
  gap: 10px;
  margin-top: 40px;
  position: relative;
  z-index: 1;
}
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot-green  { background: #219900; }
.dot-pink   { background: #ff0051; }
.dot-yellow { background: #ffe600; }
.dot-white  { background: transparent; border: 1.5px solid #ffffff; }
.login-right {
  flex: 1;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  position: relative;
}
.login-right::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--yellow);
}
.login-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
}
.login-card-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--yellow-dim);
  margin-bottom: 8px;
}
.login-card h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}
.login-card .sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 32px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
}
.form-group input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  color: var(--ink);
  background: var(--white);
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus { border-color: var(--navy); }
.btn-primary {
  width: 100%;
  background: var(--navy);
  color: var(--yellow);
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  letter-spacing: .03em;
  transition: background .15s;
}
.btn-primary:hover { background: var(--navy-mid); }
.login-msg {
  min-height: 20px;
  font-size: 13px;
  color: var(--danger);
  font-weight: 500;
  margin-top: 12px;
  text-align: center;
}
.login-footer {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
}

/* ══════════════════════════════════
   APP LAYOUT
══════════════════════════════════ */
.app-shell { min-height: 100vh; }
body.app-mode { background: var(--surface); }
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
}
.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo img {
  width: 100%;
  max-width: 170px;
  display: block;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.28);
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,.6);
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, color .12s;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); }
.nav-item.active { background: rgba(232,201,51,.12); color: var(--yellow); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--yellow);
  border-radius: 0 3px 3px 0;
}
.nav-icon { font-size: 18px; flex-shrink: 0; opacity: .8; }
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-pill { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(232,201,51,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--yellow);
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { font-size: 11px; color: rgba(255,255,255,.4); }
.btn-logout {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,.35);
  font-size: 16px;
  padding: 4px;
  border-radius: 6px;
  transition: color .12s;
}
.btn-logout:hover { color: rgba(255,255,255,.8); }
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.breadcrumb-sep { opacity: .4; }
.breadcrumb-cur { color: var(--ink); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, color .12s;
  text-decoration: none;
}
.btn-nav { background: var(--navy); color: var(--yellow); }
.btn-nav:hover { background: var(--navy-mid); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface); color: var(--ink); }
.btn-success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.btn-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #fecaca; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.content { padding: 28px; display: flex; flex-direction: column; gap: 20px; }

/* ══════════════════════════════════
   SECTIONS / TABLES
══════════════════════════════════ */
.section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: border-color .15s;
}
.section-header.open { border-bottom-color: var(--border); }
.section-title-group { display: flex; align-items: center; gap: 10px; }
.section-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  min-width: 22px;
}
.badge-navy   { background: var(--navy); color: var(--yellow); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow-dim); border: 1px solid #f0e17a; }
.badge-ok     { background: var(--success-bg); color: var(--success); }
.badge-warn   { background: var(--warn-bg); color: var(--warn); }
.badge-err    { background: var(--danger-bg); color: var(--danger); }
.badge-muted  { background: var(--surface); color: var(--muted); }
.chevron { font-size: 16px; color: var(--muted); transition: transform .2s; }
.chevron.open { transform: rotate(180deg); }
.section-body { display: none; }
.section-body.open { display: block; }
.erp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.erp-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.erp-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--ink);
}
.erp-table tr:last-child td { border-bottom: none; }
.erp-table tr:hover td { background: #fafbfc; }
.table-scroll { overflow-x: auto; }
.file-cell {
  font-weight: 600;
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prog-wrap { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.prog-bar-bg {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  min-width: 80px;
}
.prog-bar-fill { height: 100%; border-radius: 999px; background: var(--navy); }
.prog-pct { font-size: 12px; font-weight: 600; color: var(--muted); min-width: 32px; text-align: right; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; }
.s-pending     { background: var(--surface); color: var(--muted); }
.s-pending .status-dot { background: var(--muted); }
.s-scheduled   { background: var(--yellow-bg); color: var(--yellow-dim); border: 1px solid #f0e17a; }
.s-scheduled .status-dot { background: var(--yellow-dim); }
.s-processing  { background: var(--warn-bg); color: var(--warn); }
.s-processing .status-dot { background: var(--warn); animation: pulse 1.2s infinite; }
.s-done        { background: var(--success-bg); color: var(--success); }
.s-done .status-dot { background: var(--success); }
.s-done-errors { background: var(--warn-bg); color: var(--warn); }
.s-done-errors .status-dot { background: var(--warn); }
.s-failed      { background: var(--danger-bg); color: var(--danger); }
.s-failed .status-dot { background: var(--danger); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ══════════════════════════════════
   IMPORT FORM
══════════════════════════════════ */
.import-form { padding: 24px; }
.form-row { display: grid; grid-template-columns: 1fr; gap: 14px; max-width: 560px; }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: 6px;
}
.file-drop {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.file-drop:hover, .file-drop.drag-over { border-color: var(--navy); background: #f0f3f8; }
.file-drop-icon { font-size: 28px; color: var(--muted); margin-bottom: 8px; }
.file-drop p { font-size: 13px; color: var(--muted); }
.file-drop strong { color: var(--navy); }
.file-drop input { display: none; }
.file-drop-hint { font-size: 12px !important; margin-top: 4px; }
.accounts-preview-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.accounts-preview-head {
  background: var(--surface);
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.account-row-item {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.account-row-item:last-child { border-bottom: none; }
.account-login-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.erp-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--ink);
  background: var(--white);
  outline: none;
  transition: border-color .15s;
}
.erp-input:focus { border-color: var(--navy); }
.erp-select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--ink);
  background: var(--white);
  outline: none;
}

.field-hint {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}
.schedule-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
}
.schedule-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}
.schedule-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--navy);
}
.schedule-options {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.import-msg { font-size: 13px; font-weight: 500; color: var(--danger); margin-top: 8px; min-height: 20px; }
.import-msg.ok { color: var(--success); }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ══════════════════════════════════
   MODAL / ADMIN / EMPTY
══════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,30,60,.45);
  z-index: 200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: 1100px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--ink); }
.modal-subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }
.modal-body { padding: 0; overflow-x: auto; }
.modal-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.detail-summary { padding: 16px 20px; display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 12px; border-bottom: 1px solid var(--border); }
.detail-stat { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: #fff; }
.detail-stat span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.detail-stat strong { font-size: 14px; color: var(--ink); }
.admin-body { padding: 20px 24px; }
.admin-add-row {
  display: grid;
  grid-template-columns: 1fr 180px auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.admin-add-row .btn { height: 40px; align-self: end; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-icon { font-size: 36px; opacity: .35; margin-bottom: 12px; }
.empty-text { font-size: 14px; }
.empty-sub { font-size: 13px; margin-top: 4px; }
.poll-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 1.6s infinite;
  vertical-align: middle;
  margin-right: 4px;
}
.poll-label { font-size: 12px; color: var(--muted); white-space: nowrap; }

@media (max-width: 900px) {
  body.login-mode { background: var(--surface); }
  .login-screen { flex-direction: column; }
  .login-left { width: 100%; padding: 40px 28px 36px; }
  .login-left h1 { font-size: 26px; }
  .left-logo { width: 220px; margin-bottom: 28px; }
  .login-right { padding: 36px 20px 48px; }
  .main { margin-left: 0; }
  .sidebar { display: none; }
  .topbar { height: auto; min-height: var(--topbar-h); padding: 14px 18px; align-items: flex-start; flex-direction: column; }
  .topbar-actions { justify-content: flex-start; }
  .content { padding: 18px; }
  .admin-add-row { grid-template-columns: 1fr; }
  .account-row-item { grid-template-columns: 1fr; }
  .detail-summary { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  .login-card { padding: 34px 24px; }
  .detail-summary { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 20px 10px; }
  .modal-header { align-items: flex-start; flex-direction: column; }
}
