﻿    :root {
      --bg-dark: #0b0f19;
      --panel-bg: #111827;
      --card-bg: #1e293b;
      --border-color: #1f2937;
      --text-main: #f8fafc;
      --text-muted: #94a3b8;
      --cyan-accent: #00f2fe;
      --green-profit: #10b981;
      --yellow-warn: #f59e0b;
      --red-loss: #ef4444;
      --purple-accent: #8b5cf6;
    }

    body {
      background-color: var(--bg-dark);
      color: var(--text-main);
      font-family: 'Inter', sans-serif;
      margin: 0;
      padding: 0;
      overflow-x: hidden;
    }

    .page-header-bar {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 12px;
      flex-wrap: wrap;
      gap: 10px;
    }

    .page-title {
      font-size: 16px;
      font-weight: 700;
      color: #fff;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .header-actions {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .btn-action {
      background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
      color: #fff;
      border: 1px solid rgba(56, 189, 248, 0.4);
      border-radius: 6px;
      padding: 6px 12px;
      font-size: 11.5px;
      font-weight: 600;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 6px;
      transition: all 0.2s;
    }

    .btn-action:hover {
      background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
      box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
    }

    .btn-secondary {
      background: rgba(30, 41, 59, 0.8);
      border-color: #334155;
    }

    .btn-secondary:hover {
      background: rgba(51, 65, 85, 0.9);
      border-color: #475569;
    }

    .btn-success {
      background: linear-gradient(135deg, #059669 0%, #047857 100%);
      border-color: rgba(16, 185, 129, 0.4);
    }

    .btn-success:hover {
      background: linear-gradient(135deg, #047857 0%, #065f46 100%);
      box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
    }

    /* KPI Summary Strip */
    .kpi-strip {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
      gap: 8px;
      margin-bottom: 12px;
    }

    .kpi-card {
      background: rgba(17, 24, 39, 0.85);
      border: 1px solid var(--border-color);
      border-radius: 8px;
      padding: 10px 12px;
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .kpi-icon {
      width: 34px;
      height: 34px;
      border-radius: 6px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 18px;
    }

    .kpi-val {
      font-size: 14px;
      font-weight: 700;
      line-height: 1.2;
    }

    .kpi-lbl {
      font-size: 10.5px;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }

    /* Split Screen Work Area */
    .takeoff-split-container {
      display: grid;
      grid-template-columns: 42% 58%;
      gap: 12px;
      min-height: calc(100vh - 200px);
    }

    @media (max-width: 1200px) {
      .takeoff-split-container {
        grid-template-columns: 1fr;
      }
    }
    
    @media (max-width: 600px) {
      .hide-on-mobile {
        display: none !important;
      }
      .modal-content {
        max-height: calc(100dvh - 32px) !important;
        margin: 16px !important;
      }
    }

    .split-panel {
      background: rgba(17, 24, 39, 0.85);
      border: 1px solid var(--border-color);
      border-radius: 8px;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    .panel-header {
      background: rgba(15, 23, 42, 0.95);
      border-bottom: 1px solid var(--border-color);
      padding: 8px 12px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 12px;
      font-weight: 600;
    }

    /* Drawing Viewer Styles */
    .drawing-viewer-body {
      flex: 1;
      position: relative;
      background: #050811;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      min-height: 480px;
      cursor: grab;
      touch-action: none;
    }

    .drawing-viewer-body.is-dragging, .drawing-viewer-body:active {
      cursor: grabbing;
    }

    .drawing-viewer-body:fullscreen, .drawing-viewer-body:-webkit-full-screen {
      width: 100vw !important;
      height: 100vh !important;
      max-width: 100vw !important;
      max-height: 100vh !important;
      border-radius: 0 !important;
      z-index: 999999 !important;
      background: #050811 !important;
    }

    .drawing-viewer-body:fullscreen .drawing-img, .drawing-viewer-body:-webkit-full-screen .drawing-img {
      max-height: 92vh !important;
    }

    .drawing-canvas-wrapper {
      position: relative;
      max-width: 100%;
      max-height: 100%;
      transform-origin: center center;
      transition: transform 0.1s ease-out;
      user-select: none;
      -webkit-user-drag: none;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .drawing-img {
      width: 100%;
      height: 100%;
      min-height: 520px;
      max-width: none;
      max-height: none;
      object-fit: contain;
      display: block;
      border-radius: 4px;
      box-shadow: 0 4px 20px rgba(0,0,0,0.5);
      pointer-events: none;
      user-select: none;
      -webkit-user-drag: none;
    }

    .viewer-toolbar {
      position: absolute;
      bottom: 12px;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(15, 23, 42, 0.9);
      border: 1px solid #334155;
      border-radius: 20px;
      padding: 4px 10px;
      display: flex;
      gap: 6px;
      align-items: center;
      z-index: 10;
      backdrop-filter: blur(8px);
    }

    .viewer-tool-btn {
      background: transparent;
      border: none;
      color: #cbd5e1;
      cursor: pointer;
      padding: 4px;
      border-radius: 4px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .viewer-tool-btn:hover {
      background: rgba(255,255,255,0.1);
      color: #fff;
    }

    /* Sub-mode Toolbar Buttons */
    .btn-submode {
      background: transparent;
      border: 1px solid transparent;
      color: #94a3b8;
      font-size: 11px;
      font-weight: 600;
      padding: 3px 8px;
      border-radius: 4px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 4px;
      transition: all 0.15s;
    }
    .btn-submode:hover {
      background: rgba(255, 255, 255, 0.06);
      color: #fff;
    }
    .btn-submode.active {
      background: rgba(56, 189, 248, 0.15);
      border-color: rgba(56, 189, 248, 0.4);
      color: #38bdf8;
    }

    /* Drawing Selector List */
    .drawing-list-drawer {

      border-top: 1px solid var(--border-color);
      background: rgba(15, 23, 42, 0.95);
      max-height: 140px;
      overflow-y: auto;
      padding: 6px 8px;
    }

    .drawing-chip {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 5px 8px;
      border-radius: 4px;
      font-size: 11px;
      background: rgba(30, 41, 59, 0.6);
      margin-bottom: 4px;
      cursor: pointer;
      border: 1px solid transparent;
      transition: all 0.15s;
    }

    .drawing-chip:hover, .drawing-chip.active {
      background: rgba(56, 189, 248, 0.15);
      border-color: rgba(56, 189, 248, 0.4);
    }

    .chip-del-btn {
      background: transparent;
      border: none;
      color: #64748b;
      cursor: pointer;
      padding: 2px 4px;
      border-radius: 3px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: all 0.15s;
      margin-left: 4px;
    }
    .chip-del-btn:hover {
      background: rgba(239, 68, 68, 0.2);
      color: #ef4444;
    }
    .btn-danger {
      background: rgba(239, 68, 68, 0.15) !important;
      border: 1px solid rgba(239, 68, 68, 0.35) !important;
      color: #f87171 !important;
    }
    .btn-danger:hover {
      background: rgba(239, 68, 68, 0.3) !important;
      border-color: #ef4444 !important;
      color: #fff !important;
    }

    /* Page Navigation Toolbar */
    .page-nav-bar {
      background: rgba(15, 23, 42, 0.95);
      border-bottom: 1px solid var(--border-color);
      padding: 5px 10px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }

    /* Takeoff Grid Table */
    .takeoff-grid-body {
      flex: 1;
      overflow-y: auto;
      overflow-x: auto;
      max-height: 580px;
      scrollbar-width: thin;
      scrollbar-color: #334155 #0f172a;
    }

    .takeoff-table {
      width: 100%;
      table-layout: fixed;
      border-collapse: collapse;
      font-size: 11px;
      text-align: left;
    }

    .takeoff-table th {
      background: rgba(15, 23, 42, 0.98);
      color: var(--text-muted);
      font-weight: 600;
      padding: 7px 8px;
      border-bottom: 1px solid var(--border-color);
      position: sticky;
      top: 0;
      z-index: 5;
      font-size: 10.5px;
      text-transform: uppercase;
      user-select: none;
      cursor: pointer;
      overflow: hidden;
      white-space: nowrap;
      position: relative;
    }

    .takeoff-table th:hover {
      color: #38bdf8;
      background: #1e293b;
    }

    .takeoff-table td {
      padding: 6px 8px;
      border-bottom: 1px solid rgba(31, 41, 55, 0.6);
      vertical-align: middle;
      white-space: normal !important;
      word-break: break-word !important;
      overflow-wrap: break-word !important;
      line-height: 1.4;
    }

    .takeoff-table tr:hover {
      background: rgba(30, 41, 59, 0.4);
    }

    /* Resizer handles */
    .resizer {
      position: absolute;
      top: 0;
      right: 0;
      width: 5px;
      cursor: col-resize;
      user-select: none;
      height: 100%;
      z-index: 10;
    }

    .resizer:hover, .resizing {
      border-right: 2px solid #38bdf8;
    }

    .sort-icon {
      font-size: 10px;
      margin-left: 3px;
      color: #38bdf8;
    }

    .unit-price-link {
      color: #00f2fe !important;
      text-decoration: none;
      font-weight: 600;
      display: inline-flex;
      align-items: center;
      gap: 3px;
      transition: all 0.15s;
    }

    .unit-price-link:hover {
      text-decoration: underline;
      color: #38bdf8 !important;
    }

    .mono {
      font-family: 'JetBrains Mono', monospace;
    }

    .badge {
      display: inline-flex;
      align-items: center;
      padding: 2px 6px;
      border-radius: 4px;
      font-size: 9.5px;
      font-weight: 600;
      text-transform: uppercase;
    }

    .badge-blue { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.3); }
    .badge-green { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
    .badge-purple { background: rgba(139, 92, 246, 0.15); color: #c084fc; border: 1px solid rgba(139, 92, 246, 0.3); }
    .badge-amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
    .badge-red { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }

    @keyframes pulse-glow {
      0%, 100% { opacity: 1; transform: scale(1); }
      50% { opacity: 0.65; transform: scale(0.97); }
    }
    .pulse-anim { animation: pulse-glow 1.8s infinite ease-in-out; }

    /* Toast notification */
    .toast-container {
      position: fixed;
      bottom: 24px;
      right: 24px;
      z-index: 9999;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    .erp-toast {
      background: rgba(17, 24, 39, 0.96);
      border: 1px solid #334155;
      border-radius: 6px;
      padding: 10px 14px;
      font-size: 11.5px;
      color: #fff;
      display: flex;
      align-items: center;
      gap: 10px;
      box-shadow: 0 10px 25px rgba(0,0,0,0.6);
      backdrop-filter: blur(8px);
      animation: slideIn 0.3s ease-out;
    }
    .erp-toast.success { border-color: rgba(16, 185, 129, 0.5); }
    .erp-toast.info { border-color: rgba(56, 189, 248, 0.5); }
    .erp-toast.error { border-color: rgba(239, 68, 68, 0.5); }
    @keyframes slideIn {
      from { transform: translateX(100%); opacity: 0; }
      to { transform: translateX(0); opacity: 1; }
    }

    /* Modals */
    .modal-overlay {
      position: fixed;
      inset: 0;
      width: 100vw;
      height: 100dvh;
      background: rgba(0, 0, 0, 0.78);
      display: none;
      align-items: flex-start;
      justify-content: center;
      z-index: 99999;
      backdrop-filter: blur(6px);
      overflow-y: auto;
      padding: 24px 12px;
      box-sizing: border-box;
    }

    .modal-overlay.active {
      display: flex;
    }

    .modal-content {
      background: #111827;
      border: 1px solid #374151;
      border-radius: 8px;
      width: 100%;
      max-width: 580px;
      max-height: calc(100vh - 80px);
      overflow-y: auto;
      padding: 16px;
      box-shadow: 0 16px 32px rgba(0,0,0,0.6);
      margin: 0 auto;
      position: relative;
    }

    .form-group {
      margin-bottom: 10px;
    }

    .form-group label {
      display: block;
      font-size: 11px;
      color: var(--text-muted);
      margin-bottom: 4px;
      font-weight: 500;
    }

    .form-control {
      width: 100%;
      background: #0f172a;
      border: 1px solid #334155;
      border-radius: 4px;
      color: #fff;
      padding: 6px 8px;
      font-size: 11.5px;
      box-sizing: border-box;
    }

    .form-control:focus {
      outline: none;
      border-color: #38bdf8;
    }

    .file-dropzone {
      border: 2px dashed #334155;
      border-radius: 6px;
      padding: 20px;
      text-align: center;
      background: rgba(15, 23, 42, 0.5);
      cursor: pointer;
      transition: all 0.2s;
    }

    .file-dropzone:hover {
      border-color: #38bdf8;
      background: rgba(56, 189, 248, 0.05);
    }

    /* Studio Navigation Tabs */
    .studio-tab-btn {
      background: transparent;
      border: none;
      border-bottom: 2px solid transparent;
      color: var(--text-muted);
      font-size: 11.5px;
      font-weight: 600;
      padding: 8px 12px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 6px;
      transition: all 0.15s;
    }
    .studio-tab-btn:hover {
      color: #fff;
      background: rgba(255, 255, 255, 0.03);
    }
    .studio-tab-btn.active {
      color: #38bdf8;
      border-bottom-color: #38bdf8;
      background: rgba(56, 189, 248, 0.08);
    }

    /* AI Quỳnh Training Studio & Chat Styles */
    .chat-studio-container {
      display: flex;
      flex-direction: column;
      height: 100%;
      min-height: 480px;
      background: #090e1a;
    }
    .chat-messages-area {
      flex: 1;
      overflow-y: auto;
      padding: 12px;
      display: flex;
      flex-direction: column;
      gap: 12px;
      max-height: 440px;
    }
    .chat-msg-row {
      display: flex;
      gap: 10px;
      align-items: flex-start;
      animation: fadeIn 0.2s ease-in;
    }
    .chat-msg-row.user {
      flex-direction: row-reverse;
    }
    .chat-avatar {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 16px;
      flex-shrink: 0;
    }
    .chat-avatar.ai {
      background: rgba(56, 189, 248, 0.15);
      border: 1px solid rgba(56, 189, 248, 0.4);
    }
    .chat-avatar.user {
      background: rgba(245, 158, 11, 0.15);
      border: 1px solid rgba(245, 158, 11, 0.4);
    }
    .chat-bubble {
      max-width: 82%;
      border-radius: 8px;
      padding: 10px 12px;
      font-size: 11.5px;
      line-height: 1.5;
    }
    .chat-bubble.ai {
      background: #111a2e;
      border: 1px solid #1e2e4a;
      color: #f1f5f9;
    }
    .chat-bubble.user {
      background: #1e293b;
      border: 1px solid #334155;
      color: #e2e8f0;
    }
    .chat-sender-label {
      font-size: 10px;
      font-weight: 700;
      margin-bottom: 4px;
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .chat-sender-label.ai { color: #38bdf8; }
    .chat-sender-label.user { color: #f59e0b; justify-content: flex-end; }
    
    .quick-chips-bar {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      padding: 6px 12px;
      background: #0d1527;
      border-top: 1px solid var(--border-color);
    }
    .quick-chip {
      background: rgba(30, 41, 59, 0.8);
      border: 1px solid #334155;
      color: #94a3b8;
      font-size: 10.5px;
      padding: 3px 8px;
      border-radius: 12px;
      cursor: pointer;
      transition: all 0.15s;
      display: inline-flex;
      align-items: center;
      gap: 4px;
    }
    .quick-chip:hover {
      background: rgba(56, 189, 248, 0.15);
      border-color: #38bdf8;
      color: #fff;
    }

    .chat-input-bar {
      padding: 10px 12px;
      background: #0f172a;
      border-top: 1px solid var(--border-color);
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    .chat-input-row {
      display: flex;
      gap: 8px;
      align-items: flex-end;
    }
    .chat-textarea {
      flex: 1;
      background: #0b0f19;
      border: 1px solid #334155;
      border-radius: 6px;
      color: #fff;
      padding: 8px 10px;
      font-size: 11.5px;
      font-family: inherit;
      resize: none;
      min-height: 38px;
      max-height: 80px;
    }
    .chat-textarea:focus {
      outline: none;
      border-color: #38bdf8;
    }

    /* Diff / Suggested Correction Card */
    .suggested-card {
      margin-top: 8px;
      background: #090e1a;
      border: 1px solid rgba(16, 185, 129, 0.3);
      border-radius: 6px;
      padding: 8px 10px;
    }
    .suggested-card-header {
      font-size: 11px;
      font-weight: 700;
      color: #10b981;
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 6px;
    }
    .learned-rule-tag {
      background: rgba(139, 92, 246, 0.15);
      border: 1px solid rgba(139, 92, 246, 0.4);
      color: #c4b5fd;
      border-radius: 4px;
      padding: 4px 8px;
      font-size: 10.5px;
      margin-top: 6px;
      display: flex;
      gap: 6px;
      align-items: flex-start;
    }
  
    /* Pulse Dots & Realtime Thinking Animation */
    .pulse-dot {
      display: inline-block;
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: #38bdf8;
      margin-right: 4px;
      animation: pulseDot 1.4s infinite ease-in-out both;
    }
    .pulse-dot:nth-child(1) { animation-delay: -0.32s; }
    .pulse-dot:nth-child(2) { animation-delay: -0.16s; }
    .pulse-dot:nth-child(3) { animation-delay: 0s; }
    @keyframes pulseDot {
      0%, 80%, 100% { transform: scale(0.2); opacity: 0.3; }
      40% { transform: scale(1); opacity: 1; }
    }
    .chat-bubble.thinking {
      border: 1px dashed rgba(56, 189, 248, 0.6);
      background: rgba(14, 165, 233, 0.08);
    }
    .thinking-content {
      display: flex;
      align-items: center;
      gap: 4px;
      color: #38bdf8;
      font-size: 11px;
    }

