/* MW spot ERP - Dashboard Styles */
:root {
  --primary: #0a2a44;
  --accent: #0066b3;
  --sidebar-width: 240px;
  --header-height: 56px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  background: #f0f2f5;
  min-height: 100vh;
}

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--primary);
  color: #b0b8c1;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-brand {
  padding: 18px 20px;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-decoration: none;
}

.erp-brand-logo,
.login-brand-logo {
  position: relative;
  display: block;
  overflow: hidden;
  background: #fff;
}

.erp-brand-logo {
  width: 150px;
  height: 34px;
  border-radius: 5px;
}

.erp-brand-logo img,
.login-brand-logo img {
  position: absolute;
  height: auto;
  max-width: none;
}

.erp-brand-logo img {
  width: 169px;
  left: -9px;
  top: -21px;
}

.erp-brand-suffix {
  color: #d7e3ec;
  font-size: 12px;
  letter-spacing: 0.14em;
}

.sidebar-nav { padding: 12px 0; }

.sidebar-nav .nav-section {
  padding: 16px 20px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #5a6a7a;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: #b0b8c1;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: #fff;
  background: rgba(255,255,255,0.06);
  border-left-color: var(--accent);
}

.sidebar-nav a .badge {
  margin-left: auto;
  font-size: 11px;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
}

/* Top bar */
.topbar {
  background: #fff;
  border-bottom: 1px solid #e0e4e8;
  padding: 0 24px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar .breadcrumb { font-size: 13px; color: #888; }
.topbar .breadcrumb a { color: var(--accent); text-decoration: none; }
.topbar .user-menu { display: flex; align-items: center; gap: 14px; }
.topbar .user-menu a { color: #666; text-decoration: none; font-size: 13px; }
.topbar .user-menu a:hover { color: var(--accent); }

/* Page Content */
.page-content { padding: 24px; }

.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 { font-size: 22px; font-weight: 700; color: var(--primary); margin: 0; }

/* Cards */
.card {
  background: #fff;
  border: 1px solid #e0e4e8;
  border-radius: 8px;
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e0e4e8;
  font-weight: 600;
  font-size: 15px;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: 20px; }

/* Stat Cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border: 1px solid #e0e4e8;
  border-radius: 8px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.blue { background: #e6f2ff; color: #0066b3; }
.stat-icon.green { background: #e6ffe6; color: #28a745; }
.stat-icon.orange { background: #fff3e6; color: #ff8c00; }
.stat-icon.purple { background: #f0e6ff; color: #6f42c1; }
.stat-icon.red { background: #ffe6e6; color: #dc3545; }

.stat-info .stat-value { font-size: 24px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat-info .stat-label { font-size: 12px; color: #888; }

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  background: #f5f7fa;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--primary);
  border-bottom: 2px solid #e0e4e8;
  white-space: nowrap;
}

.table td {
  padding: 10px 14px;
  border-bottom: 1px solid #e0e4e8;
  vertical-align: middle;
}

.table tbody tr:hover { background: #fafbfc; }

.table .actions { white-space: nowrap; }
.table .actions a { margin-right: 8px; font-size: 12px; }

/* Forms */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,102,179,0.12);
}

textarea.form-control { min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.15s;
  text-align: center;
  line-height: 1.5;
}

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #005291; color: #fff; }
.btn-success { background: #28a745; color: #fff; border-color: #28a745; }
.btn-success:hover { background: #218838; }
.btn-danger { background: #dc3545; color: #fff; border-color: #dc3545; }
.btn-danger:hover { background: #c82333; }
.btn-warning { background: #ffc107; color: #333; border-color: #ffc107; }
.btn-secondary { background: #6c757d; color: #fff; border-color: #6c757d; }
.btn-outline-primary { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline-primary:hover { background: var(--accent); color: #fff; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-primary { background: #cce5ff; color: #004085; }
.badge-secondary { background: #e2e3e5; color: #383d41; }
.badge-dark { background: #d6d8d9; color: #1b1e21; }

/* Search bar */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-bar .form-control { max-width: 320px; }

/* Pagination */
.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 20px;
}

.pagination a, .pagination span {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid #e0e4e8;
  border-radius: 4px;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
}

.pagination .current {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Alerts */
.alert {
  padding: 12px 18px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}

.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* Detailed info grid */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  font-size: 13px;
}

.info-grid .info-row {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.info-row .info-label {
  width: 140px;
  font-weight: 600;
  color: var(--primary);
  flex-shrink: 0;
}

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), #0d3b5e);
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 380px;
  max-width: 90%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.login-brand-logo {
  width: 240px;
  height: 51px;
  margin: 0 auto 14px;
}

.login-brand-logo img {
  width: 270px;
  left: -15px;
  top: -34px;
}

.login-card h2 {
  font-size: 24px; font-weight: 700; color: var(--primary);
  text-align: center; margin-bottom: 8px;
}

.login-card .subtitle { text-align: center; color: #888; margin-bottom: 28px; font-size: 13px; }

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-bar .form-control {
  width: auto;
  min-width: 150px;
}

/* Quote/Order items inline */
.item-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 40px;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f0f0f0;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .item-row {
    grid-template-columns: 1fr;
  }
}

/* 10-digit model code generator */
.code-page-header { align-items: flex-end; }
.code-page-header p { margin: 7px 0 0; color: #607080; }
.code-kicker { color: #b36b00; font: 700 11px/1.2 Consolas, monospace; letter-spacing: 1.8px; margin-bottom: 5px; }
.code-rule-chip { background: #0a2a44; color: #fff; border-left: 5px solid #d88716; padding: 12px 16px; font: 700 15px Consolas, monospace; letter-spacing: 2px; }
.code-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(310px, .75fr); gap: 20px; align-items: stretch; }
.code-form-card { margin: 0; }
.code-form-card .form-control { box-sizing: border-box; min-width: 0; }
.code-status { color: #8a5b11; font: 700 11px Consolas, monospace; text-transform: uppercase; letter-spacing: 1px; }
.code-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.code-span-2 { grid-column: span 2; }
.code-form-grid small { display: block; color: #7d8790; margin-top: 5px; }
.code-actions { display: flex; gap: 10px; padding-top: 3px; }
.code-product-link { border-top: 1px solid #e4e9ed; margin-top: 18px; padding-top: 15px; }
.code-check { display: inline-flex !important; align-items: center; gap: 8px; cursor: pointer; }
.code-product-fields { display: none; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.code-product-fields.is-open { display: grid; }
.code-result-panel { background: linear-gradient(150deg, #0a2a44 0%, #103d60 72%, #174d73 100%); color: #fff; padding: 28px; position: relative; overflow: hidden; }
.code-result-panel::after { content: ''; position: absolute; right: -65px; bottom: -80px; width: 220px; height: 220px; border: 24px solid rgba(255,255,255,.05); border-radius: 50%; }
.code-result-label { color: #8db4cf; font: 700 11px Consolas, monospace; letter-spacing: 2px; }
.code-result { border-bottom: 2px solid #d88716; padding: 18px 0 14px; font: 700 clamp(24px, 3vw, 39px) Consolas, monospace; letter-spacing: 3px; white-space: nowrap; }
.code-slot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 22px; position: relative; z-index: 1; }
.code-slot-grid div { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.09); padding: 9px 10px; }
.code-slot-grid b { display: block; color: #fff; font: 700 16px Consolas, monospace; }
.code-slot-grid span { color: #9db7c9; font-size: 11px; }
.code-message { background: rgba(0,0,0,.17); border-left: 3px solid #d88716; color: #c9d9e4; margin-top: 18px; padding: 12px; font-size: 12px; line-height: 1.6; position: relative; z-index: 1; }
.code-message.is-error { border-left-color: #f06c64; color: #ffd8d5; }
.code-import-card { margin-top: 20px; }
.code-import-row { display: grid; grid-template-columns: 1fr minmax(260px, 420px) auto; gap: 16px; align-items: center; }
.code-import-row p { color: #7b8791; font-size: 12px; margin: 5px 0 0; }
.code-table-model { color: #0a527f; font-weight: 700; letter-spacing: 1px; }
.code-empty { text-align: center; color: #88939c; padding: 26px !important; }

@media (max-width: 1050px) {
  .code-layout { grid-template-columns: 1fr; }
  .code-import-row { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .code-form-grid, .code-product-fields { grid-template-columns: 1fr; }
  .code-span-2 { grid-column: span 1; }
  .code-result { font-size: 25px; letter-spacing: 2px; }
}

/* FTP/PHP edition */
:root { --mw-navy:#082f57; --mw-blue:#0d6efd; --mw-red:#ef233c; --mw-paper:#f4f7fa; }
.ftp-app { min-height:100vh; background:var(--mw-paper); }
.ftp-logo { display:block; max-width:150px; max-height:58px; object-fit:contain; background:#fff; border-radius:8px; padding:6px 10px; }
.ftp-sidebar { position:fixed; inset:0 auto 0 0; width:230px; padding:22px 16px; color:#fff; background:linear-gradient(165deg,#062849,#0b4f83); z-index:20; overflow:auto; }
.ftp-sidebar h1 { margin:12px 0 24px; font-size:16px; letter-spacing:2px; }
.ftp-nav button { display:block; width:100%; border:0; padding:11px 12px; margin:3px 0; border-radius:7px; color:#dceaf6; background:transparent; text-align:left; cursor:pointer; font-size:14px; }
.ftp-nav button:hover,.ftp-nav button.active { background:rgba(255,255,255,.14); color:#fff; }
.ftp-main { margin-left:230px; min-height:100vh; }
.ftp-topbar { height:66px; display:flex; align-items:center; justify-content:space-between; padding:0 28px; background:#fff; border-bottom:1px solid #dfe6ed; position:sticky; top:0; z-index:10; }
.ftp-content { padding:26px; max-width:1500px; margin:auto; }
.ftp-panel { display:none; }.ftp-panel.active { display:block; animation:ftpIn .22s ease; }
@keyframes ftpIn { from { opacity:0; transform:translateY(5px) } to { opacity:1; transform:none } }
.ftp-title { margin:0 0 20px; color:var(--mw-navy); font-size:27px; }
.ftp-stat-grid { display:grid; grid-template-columns:repeat(5,minmax(140px,1fr)); gap:14px; }
.ftp-stat { background:#fff; border:1px solid #e0e7ed; border-radius:10px; padding:19px; box-shadow:0 4px 15px rgba(8,47,87,.05); }
.ftp-stat b { display:block; color:var(--mw-navy); font:700 28px Consolas,monospace; }.ftp-stat span { color:#6b7783; font-size:12px; }
.ftp-grid { display:grid; grid-template-columns:minmax(480px,1fr) minmax(360px,.7fr); gap:18px; }
.ftp-card { background:#fff; border:1px solid #dfe6ed; border-radius:10px; margin-bottom:18px; overflow:hidden; }
.ftp-card-head { padding:14px 18px; border-bottom:1px solid #e5ebf0; color:var(--mw-navy); font-weight:700; display:flex; justify-content:space-between; align-items:center; }
.ftp-card-body { padding:18px; }.ftp-form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px 16px; }
.ftp-field label { display:block; font-size:12px; font-weight:700; color:#4b5965; margin-bottom:5px; }.ftp-span-2 { grid-column:span 2; }
.ftp-model { padding:24px 10px; text-align:center; color:var(--mw-navy); background:linear-gradient(135deg,#eef7ff,#fff); font:700 clamp(28px,4vw,48px) Consolas,monospace; letter-spacing:4px; }
.ftp-slots { display:grid; grid-template-columns:repeat(9,1fr); gap:3px; margin-top:12px; }.ftp-slots span { text-align:center; background:#edf2f6; padding:8px 2px; font:700 16px Consolas,monospace; }
.ftp-actions { display:flex; gap:10px; flex-wrap:wrap; margin-top:16px; }.ftp-status { min-height:22px; margin-top:12px; color:#52616e; }.ftp-status.error { color:#b42318; }
.ftp-table-wrap { overflow:auto; max-height:min(550px,calc(100vh - 250px)); overscroll-behavior:contain; }.ftp-table { width:100%; border-collapse:separate; border-spacing:0; min-width:900px; }.ftp-table th,.ftp-table td { padding:9px 10px; border-bottom:1px solid #e7ecf0; text-align:left; font-size:12px; white-space:nowrap; vertical-align:middle; }.ftp-table th { position:sticky; top:0; z-index:2; background:#eef3f7; color:#334c62; }
.ftp-table .ftp-wrap { min-width:180px; max-width:320px; white-space:normal; line-height:1.55; overflow-wrap:anywhere; }
.ftp-table-actions th:last-child,.ftp-table-actions td:last-child { position:sticky; right:0; z-index:1; min-width:128px; background:#fff; box-shadow:-8px 0 12px -12px rgba(8,47,87,.55); }
.ftp-table-actions th:last-child { z-index:3; background:#eef3f7; }
.ftp-click-row { cursor:pointer; transition:background-color .15s ease; }.ftp-click-row:hover td,.ftp-click-row:hover td:last-child { background:#eef7ff; }
.ftp-code { color:#063b6b; font:700 13px Consolas,monospace; }.ftp-file { max-width:360px; }.ftp-muted { color:#74808b; font-size:12px; }
.ftp-entity-tabs { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px; }.ftp-entity-tabs button.active { background:var(--mw-navy); color:#fff; }
.ftp-modal-open { overflow:hidden; }.ftp-modal { position:fixed; inset:0; background:rgba(2,19,34,.62); display:none; place-items:center; z-index:50; padding:20px; }.ftp-modal.open { display:grid; animation:ftpModalFade .16s ease; }.ftp-modal-card { width:min(560px,100%); max-height:calc(100vh - 40px); overflow:auto; background:#fff; border-radius:12px; padding:22px; box-sizing:border-box; box-shadow:0 24px 70px rgba(0,20,38,.32); }.ftp-modal-wide { width:min(900px,100%); }
.ftp-modal-head { position:sticky; top:-22px; z-index:4; display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin:-22px -22px 20px; padding:19px 22px 14px; background:#fff; border-bottom:1px solid #e3e9ee; }.ftp-modal-head h3 { margin:0; color:var(--mw-navy); }.ftp-modal-head p { margin:5px 0 0; }
.ftp-modal-x { flex:0 0 auto; width:36px; height:36px; border:0; border-radius:50%; background:#edf2f6; color:#29465e; font-size:24px; line-height:1; cursor:pointer; }.ftp-modal-x:hover { background:#dce8f1; }
.ftp-modal-actions { position:sticky; bottom:-22px; z-index:4; margin:20px -22px -22px; padding:14px 22px 18px; background:#fff; border-top:1px solid #e3e9ee; }
.ftp-detail-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }.ftp-detail-grid>div { padding:12px 14px; border:1px solid #e3e9ee; border-radius:8px; background:#f8fafc; }.ftp-detail-grid span { display:block; color:#73808b; font-size:11px; margin-bottom:4px; }.ftp-detail-grid strong { color:#213b50; overflow-wrap:anywhere; }
.ftp-detail-message { margin-top:16px; padding:17px; border-left:4px solid var(--mw-blue); background:#f4f8fb; }.ftp-detail-message strong { color:var(--mw-navy); }.ftp-detail-message p { margin:9px 0 0; white-space:pre-wrap; line-height:1.75; overflow-wrap:anywhere; }
.ftp-result-notes { margin-top:14px; padding:12px; border:1px solid #dce6ee; border-radius:7px; background:#f8fbfd; }.ftp-result-notes strong { color:var(--mw-navy); font-size:12px; }.ftp-result-notes p { margin:6px 0 0; color:#596b79; line-height:1.6; white-space:pre-wrap; overflow-wrap:anywhere; }
@keyframes ftpModalFade { from { opacity:0 } to { opacity:1 } }
.ftp-toast { position:fixed; right:22px; bottom:22px; background:#08365f; color:#fff; padding:12px 17px; border-radius:7px; z-index:80; opacity:0; transform:translateY(15px); transition:.2s; }.ftp-toast.show { opacity:1; transform:none; }.ftp-toast.error { background:#a61b24; }
@media(max-width:1000px){.ftp-sidebar{position:static;width:auto;padding:14px 16px}.ftp-sidebar h1{display:none}.ftp-logo{max-height:42px;margin-bottom:10px}.ftp-main{margin-left:0}.ftp-nav{display:flex;overflow:auto;scrollbar-width:thin}.ftp-nav button{width:auto;white-space:nowrap}.ftp-stat-grid{grid-template-columns:repeat(2,1fr)}.ftp-grid{grid-template-columns:1fr}.ftp-content{padding:16px}.ftp-table-wrap{max-height:calc(100vh - 215px)}}
@media(max-width:620px){.ftp-form-grid,.ftp-detail-grid{grid-template-columns:1fr}.ftp-span-2{grid-column:auto}.ftp-stat-grid{grid-template-columns:1fr 1fr}.ftp-topbar{height:auto;min-height:58px;padding:10px 15px;gap:10px;flex-wrap:wrap}.ftp-model{letter-spacing:1px}.ftp-title{font-size:23px}.ftp-responsive-head{align-items:stretch;flex-direction:column}.ftp-responsive-head .form-control{max-width:none!important}.ftp-modal{padding:8px}.ftp-modal-card{max-height:calc(100vh - 16px);padding:16px}.ftp-modal-head{top:-16px;margin:-16px -16px 16px;padding:15px 16px 12px}.ftp-modal-actions{bottom:-16px;margin:18px -16px -16px;padding:12px 16px 15px}.ftp-table-wrap{max-height:calc(100vh - 190px)}}
