:root {
  --blue: #112c4a;
  --gold: #c9a24f;
  --text: #253244;
  --muted: #667085;
  --line: #e4e7ec;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --danger: #b42318;
  --green: #067647;
  --shadow: 0 14px 34px rgba(17, 44, 74, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #102b49, #173b60);
}

.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 24px 70px rgba(4, 18, 34, 0.28);
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
}

.sidebar {
  background: linear-gradient(180deg, var(--blue), #0d2239);
  color: #fff;
  padding: 0 16px 22px;
  overflow-x: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-sidebar {
  width: calc(100% + 32px);
  min-height: 128px;
  margin: 0 -16px 20px;
  padding: 24px 18px 22px;
  background: #fff;
  border-bottom: 1px solid rgba(17, 44, 74, 0.08);
}

.brand-card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 80px;
}

.brand-logo {
  width: 214px;
  height: 82px;
  max-width: 214px;
  max-height: 82px;
  object-fit: contain;
  display: block;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: var(--gold);
  font-weight: 800;
}

.sidebar .brand h1,
.sidebar .brand small {
  display: none;
}

.nav {
  display: grid;
  gap: 7px;
}

.nav a {
  position: relative;
  padding: 13px 14px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 700;
  line-height: 1.2;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: translateX(2px);
}

.nav a.active {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.nav a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 11px;
  bottom: 11px;
  width: 3px;
  border-radius: 3px;
  background: var(--gold);
}

.main {
  min-width: 0;
  overflow-x: hidden;
}

.topbar {
  height: 72px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
}

.topbar strong {
  color: var(--blue);
}

.content {
  max-width: 1520px;
  padding: 30px;
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.page-title h2 {
  margin: 0;
  color: var(--blue);
  font-size: 30px;
  line-height: 1.15;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px 22px;
  box-shadow: 0 1px 2px rgba(17, 44, 74, 0.03);
}

.stat-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.stat-value {
  margin-top: 10px;
  color: var(--blue);
  font-size: 34px;
  line-height: 1;
  font-weight: 850;
}

.stat-link {
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.stat-link:hover {
  transform: translateY(-2px);
  border-color: rgba(201, 162, 79, 0.55);
  box-shadow: var(--shadow);
}

.stat-link.urgent {
  border-color: rgba(201, 162, 79, 0.75);
  background: linear-gradient(180deg, #fff, #fffaf0);
}

.stat-link.danger {
  border-color: rgba(180, 35, 24, 0.22);
  background: linear-gradient(180deg, #fff, #fff8f7);
}

.mini-grid .stat-value {
  font-size: 28px;
}

.workflow {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(17, 44, 74, 0.03);
}

.workflow span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.workflow strong {
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid var(--line);
  color: var(--blue);
  font-size: 13px;
  padding: 8px 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(17, 44, 74, 0.03);
}

.panel-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-head h3 {
  margin: 0;
  color: var(--blue);
  font-size: 20px;
}

.table-wrap {
  overflow-x: auto;
}

.table-input {
  min-width: 150px;
  height: 38px;
  padding: 7px 9px;
  font-size: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: #f8fafc;
  color: #475467;
  font-weight: 800;
}

tr:hover td {
  background: #fcfdff;
}

.muted { color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: #eef4ff;
  color: #175cd3;
  font-size: 12px;
  font-weight: 800;
}

.badge.red {
  background: #fef3f2;
  color: var(--danger);
}

.badge.green {
  background: #ecfdf3;
  color: var(--green);
}

.badge.warn {
  background: #fff7e6;
  color: #93620f;
}

.badge.stage-new {
  background: #eef4ff;
  color: #175cd3;
}

.badge.stage-replied,
.badge.stage-following {
  background: #eff6ff;
  color: #1d4ed8;
}

.badge.stage-waiting {
  background: #fff7e6;
  color: #93620f;
}

.badge.stage-quote-pending {
  background: #f5f3ff;
  color: #6941c6;
}

.badge.stage-quoted {
  background: #e0f2fe;
  color: #0369a1;
}

.badge.stage-hot {
  background: #ecfdf3;
  color: #027a48;
}

.badge.stage-done {
  background: #dcfce7;
  color: #166534;
}

.badge.stage-lost {
  background: #f2f4f7;
  color: #475467;
}

.badge.stage-invalid {
  background: #fef3f2;
  color: #b42318;
}

.field-alert {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 16px;
  margin-bottom: 18px;
  border: 1px solid rgba(201, 162, 79, 0.35);
  border-radius: 8px;
  background: #fffcf5;
}

.stage-help {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}

.stage-help div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.stage-help strong {
  display: block;
  color: var(--blue);
  margin-bottom: 6px;
}

.stage-help span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}

.role-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.role-grid strong {
  display: block;
  color: var(--blue);
  margin-bottom: 6px;
}

.role-grid span,
.field small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 22px;
}

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 7px;
}

.detail-grid strong {
  color: var(--blue);
}

.record-box {
  margin: 0 22px 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.record-box h4 {
  margin: 0 0 10px;
  color: var(--blue);
}

.record-box p {
  margin: 0;
  line-height: 1.7;
  color: var(--text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(17, 44, 74, 0.14);
}

.btn:hover {
  background: #0d2239;
}

.btn.secondary {
  background: #fff;
  color: var(--blue);
  border: 1px solid var(--line);
  box-shadow: none;
}

.btn.gold {
  background: var(--gold);
  color: #121212;
  box-shadow: 0 8px 18px rgba(201, 162, 79, 0.18);
}

.btn.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: 7px;
  box-shadow: none;
}

.btn.ghost {
  background: #fff;
  color: var(--blue);
  border: 1px solid var(--line);
}

.btn.danger {
  background: #fff1f0;
  color: #b42318;
  border: 1px solid #f6c7c1;
}

.btn.small.danger {
  min-height: 30px;
  box-shadow: none;
}

.row-actions {
  min-width: 116px;
  white-space: nowrap;
}

.action-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

.security-note {
  margin: 0;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  background: #fbfcfe;
}

.batch-bar {
  display: grid;
  grid-template-columns: auto 130px 130px 150px minmax(240px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fbfcff;
}

.batch-bar.compact {
  grid-template-columns: auto minmax(240px, 1fr) auto;
}

.batch-bar strong {
  color: var(--blue);
  white-space: nowrap;
}

.batch-bar select,
.batch-bar input {
  height: 38px;
  padding: 0 10px;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.filter-bar strong {
  color: var(--blue);
}

.filter-bar select {
  width: 220px;
  height: 38px;
  padding: 0 10px;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.check-label input,
td input[type="checkbox"] {
  width: auto;
  padding: 0;
}

.test-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 22px;
}

.work-table {
  min-width: 1180px;
}

.file-preview {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.file-preview img {
  max-width: 220px;
  max-height: 160px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  object-fit: contain;
}

.file-name {
  color: var(--blue);
  font-weight: 800;
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  padding: 12px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(201, 162, 79, 0.85);
  box-shadow: 0 0 0 3px rgba(201, 162, 79, 0.14);
}

textarea {
  min-height: 94px;
  resize: vertical;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

.notice,
.error {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.notice {
  background: #ecfdf3;
  color: var(--green);
  border: 1px solid #abefc6;
}

.error {
  background: #fef3f2;
  color: var(--danger);
  border: 1px solid #fecdca;
}

.install {
  max-width: 880px;
  margin: 36px auto;
  padding: 0 18px;
}

@media (max-width: 1100px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 920px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    padding-bottom: 16px;
  }

  .brand-sidebar {
    min-height: 96px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid,
  .form-grid,
  .stage-help,
  .role-grid,
  .batch-bar,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 20px;
  }
}


/* ===== CRM UI polish v4.4 production visual upgrade ===== */
.topbar{
  align-items:center;
  min-height:64px;
}
.topbar .muted{
  font-size:14px;
  font-weight:500;
}
.sidebar .nav a{
  border-radius:10px;
  margin:3px 10px;
  transition:all .2s ease;
}
.sidebar .nav a:hover{
  transform:translateX(2px);
}
.card{
  border-radius:16px;
  box-shadow:0 8px 24px rgba(15,23,42,.06);
  border:1px solid rgba(148,163,184,.18);
}
.stat-label{
  letter-spacing:.2px;
  font-size:14px;
}
.stat-value{
  font-size:28px;
  font-weight:700;
  margin-top:8px;
}
.panel{
  border-radius:16px;
  box-shadow:0 8px 24px rgba(15,23,42,.05);
}
.panel-head h3{
  font-size:18px;
}
.workflow{
  border-radius:16px;
  padding:18px 22px;
  display:flex;
  align-items:center;
  gap:14px;
  flex-wrap:wrap;
}
.workflow span{
  font-weight:700;
  margin-right:8px;
}
.workflow strong{
  padding:8px 14px;
  border-radius:999px;
  font-size:14px;
  font-weight:600;
}
.table-wrap{
  border-radius:14px;
  overflow:hidden;
}
