*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #4a90d9;
  --primary-dark: #357abd;
  --danger: #e74c3c;
  --success: #27ae60;
  --warning: #f39c12;
  --bg: #f5f7fa;
  --sidebar-bg: #2c3e50;
  --sidebar-text: #ecf0f1;
  --sidebar-active: #3498db;
  --card-bg: #fff;
  --border: #ddd;
  --text: #333;
  --text-light: #666;
  --bg-light: #eef1f5;
  --radius: 6px;
}
html { font-size: 14px; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; transition: transform .2s; }
.sidebar-header { padding: 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-header h2 { font-size: 16px; font-weight: 600; }
.sidebar-close { display: none; }
.sidebar-menu { list-style: none; padding: 8px 0; flex: 1; overflow-y: auto; }
.sidebar-menu li a { display: block; padding: 10px 16px; color: var(--sidebar-text); text-decoration: none; font-size: 13px; transition: background .15s; }
.sidebar-menu li a:hover { background: rgba(255,255,255,.1); }
.sidebar-menu li a.active { background: var(--sidebar-active); }
.menu-label { padding: 12px 16px 4px; font-size: 11px; text-transform: uppercase; opacity: .6; }
.menu-divider { height: 1px; background: rgba(255,255,255,.1); margin: 8px 16px; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 8px; }
.sidebar-footer .language-selector { display: flex; gap: 4px; align-items: center; justify-content: center; }
.sidebar-footer .lang-link { cursor: pointer; color: rgba(255,255,255,.6); font-size: 12px; padding: 2px 6px; border-radius: 3px; transition: color .2s; }
.sidebar-footer .lang-link:hover { color: #fff; }
.sidebar-footer .lang-link.active { color: #fff; font-weight: 600; background: rgba(255,255,255,.1); }
.btn-link { background: none; border: none; color: var(--sidebar-text); cursor: pointer; font-size: 12px; padding: 4px 8px; }
.btn-link:hover { text-decoration: underline; }

.mobile-header { display: none; background: var(--sidebar-bg); color: #fff; padding: 10px 16px; align-items: center; position: sticky; top: 0; z-index: 99; }
.mobile-header .hamburger { background: none; border: none; color: #fff; font-size: 24px; cursor: pointer; padding: 0 8px 0 0; line-height: 1; }
.mobile-title { flex: 1; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-header-right { flex-shrink: 0; }

.main-content { margin-left: 220px; flex: 1; padding: 24px; min-height: 100vh; }

@media (max-width: 767px) {
  .sidebar:not(.open) {
    display: none !important;
  }

  .sidebar.open {
    display: flex !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    top: 0; left: 0;
    background: var(--sidebar-bg);
    z-index: 200;
    transform: none;
    box-shadow: none;
    overflow: auto;
  }
  .sidebar.open ~ .main-content { pointer-events: none; }
  .sidebar.open .sidebar-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .sidebar.open .sidebar-header h2 { font-size: 17px; }
  .sidebar.open .sidebar-menu { padding: 4px 0; }
  .sidebar.open .sidebar-menu li a { padding: 14px 20px; font-size: 16px; }
  .sidebar.open .sidebar-menu li.menu-label { padding: 16px 20px 6px; font-size: 12px; }
  .sidebar.open .menu-divider { margin: 6px 20px; }
  .sidebar.open .sidebar-footer { padding: 14px 20px; gap: 12px; flex-wrap: wrap; justify-content: center; }
  .sidebar.open .sidebar-footer .lang-link { font-size: 15px; padding: 8px 16px; }
  .sidebar.open .btn-link { font-size: 15px; padding: 8px 16px; }

  .sidebar.open .sidebar-close {
    display: inline-block;
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
  }

  .mobile-header { display: flex; padding: 10px 14px; }
  .mobile-header .hamburger { font-size: 26px; padding: 0 10px 0 0; }
  .mobile-title { font-size: 16px; }
  .main-content { margin-left: 0; padding: 12px; }
  .mobile-header-right .btn-link { color: rgba(255,255,255,.8); font-size: 13px; padding: 4px 8px; }

  /* Tables → Cards */
  .table-wrapper { overflow: visible; }
  .table, .table tbody, .table tr { display: block; }
  .table thead { display: none; }
  .table tr { background: var(--card-bg); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.08); border: 1px solid var(--border); }
  .table td { display: flex; padding: 6px 0; border: none; font-size: 13px; align-items: center; gap: 8px; white-space: normal; }
  .table td:before { content: attr(data-label); font-weight: 600; color: var(--text-light); min-width: 80px; flex-shrink: 0; font-size: 12px; }
  .table td:empty:before { display: none; }
  .table td:last-child { padding-top: 8px; margin-top: 6px; border-top: 1px solid var(--border); justify-content: center; }
  .table td:last-child:before { display: none; }
  .table td .badge { margin-left: 0; }
  .table tbody tr:hover { background: var(--card-bg); }
  .thumb { width: 32px; height: 32px; }

  /* Page header */
  .page-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .page-header h1 { font-size: 18px; }
  .page-header .btn, .page-header a.btn, .page-header button { text-align: center; }

  /* Forms */
  .form-row { flex-direction: column; gap: 0; }
  .spec-row { flex-direction: column; gap: 6px; }
  .spec-row input { width: 100%; }
  .form { max-width: 100%; }
  .form-actions .btn { flex: 1; text-align: center; }
  .btn { padding: 12px 18px; font-size: 15px; }
  .btn-sm { padding: 8px 14px; font-size: 14px; }
  .card { padding: 14px; }
  .info-table td:first-child { width: auto; min-width: 80px; }

  /* Product grid */
  .product-grid { grid-template-columns: 1fr; gap: 12px; }
  .product-card { padding: 12px; }
  .product-card-img { height: 180px; }
  .product-card-name { font-size: 16px; }
  .product-card-price { font-size: 20px; }

  /* Stats */
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 20px; }

  /* Misc */
  .login-container { padding: 28px 20px; margin: 12px; }
  .login-container h1 { font-size: 20px; }
  .filters { display: flex; flex-direction: column; gap: 8px; }
  .filters select { width: 100%; padding: 10px 12px; font-size: 14px; }
  .order-summary { padding: 16px; margin: 0 0 20px; }
  .lang-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 0; }
  .lang-tab { padding: 10px 16px; font-size: 14px; white-space: nowrap; }
  .pagination a { padding: 10px 16px; font-size: 14px; }
  .upload-area { min-height: 100px; padding: 16px; }
}

/* Components */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 20px; font-weight: 600; }

.btn, button.btn, a.btn { display: inline-block; padding: 8px 16px; border: 1px solid var(--border); background: var(--card-bg); color: var(--text); border-radius: var(--radius); cursor: pointer; font-size: 13px; text-decoration: none; transition: all .15s; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #c0392b; border-color: #c0392b; color: #fff; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #1e8449; border-color: #1e8449; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { display: block; width: 100%; }

.form { max-width: 600px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 4px; font-size: 13px; }
.form-group label .hint { font-weight: 400; font-size: 11px; font-style: italic; color: #999; margin-left: 4px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; transition: border-color .15s; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-group small { display: block; color: var(--text-light); font-size: 12px; margin-top: 4px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.form-actions { margin-top: 20px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.form-control { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; }

.spec-row { display: flex; gap: 8px; margin-bottom: 8px; }
.spec-row input { flex: 1; }

.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.alert-error { background: #fde8e8; color: var(--danger); border: 1px solid #f8d7da; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }

.table-wrapper { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--card-bg); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
.table th { background: #f8f9fa; font-weight: 600; white-space: nowrap; }
.table tbody tr:hover { background: #f8f9fa; }
.table tfoot td { font-weight: 600; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 500; }
.badge-pending { background: #fff3cd; color: #856404; }
.badge-processing { background: #cce5ff; color: #004085; }
.badge-completed { background: #d4edda; color: #155724; }
.badge-cancelled { background: #f8d7da; color: #721c24; }
.badge-active { background: #d4edda; color: #155724; }
.badge-inactive { background: #e9ecef; color: #495057; }

.pagination { display: flex; justify-content: center; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.pagination a { display: inline-block; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); font-size: 13px; }
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination a:hover:not(.active) { border-color: var(--primary); }

.filters select { padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }

.card { background: var(--card-bg); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.info-table { width: 100%; }
.info-table td { padding: 8px 12px; font-size: 13px; border-bottom: 1px solid var(--border); }
.info-table td:first-child { font-weight: 500; color: var(--text-light); width: 120px; }

/* Login */
.login-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.login-container { background: #fff; padding: 40px; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.15); width: 100%; max-width: 400px; margin: 16px; }
.login-container h1 { text-align: center; margin-bottom: 24px; font-size: 22px; color: var(--text); }
.login-container .language-selector { text-align: center; margin-top: 20px; display: flex; justify-content: center; gap: 8px; }
.login-container .lang-link { cursor: pointer; color: var(--text-light); font-size: 13px; padding: 4px 10px; border-radius: 4px; transition: color .2s, background .2s; }
.login-container .lang-link:hover { color: var(--primary); background: var(--bg-light); }
.login-container .lang-link.active { color: var(--primary); font-weight: 600; background: var(--bg-light); }

/* Product grid (order page) */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 24px; }
.product-card { background: var(--card-bg); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); display: flex; flex-direction: column; }
.product-card-img { width: 100%; height: 160px; object-fit: cover; border-radius: 4px; margin-bottom: 12px; }
.product-card-img-placeholder { width: 100%; height: 160px; background: #f0f0f0; border-radius: 4px; margin-bottom: 12px; }
.product-card-name { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.product-card-desc { font-size: 12px; color: var(--text-light); margin-bottom: 8px; }
.product-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.product-card-price { font-size: 18px; font-weight: 700; color: var(--danger); }
.product-card-qty { display: flex; align-items: center; gap: 4px; }
.product-card-qty button { width: 28px; height: 28px; border: 1px solid var(--border); background: var(--card-bg); border-radius: 4px; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.product-card-qty button:hover { border-color: var(--primary); }
.product-card-qty input { width: 48px; text-align: center; border: 1px solid var(--border); border-radius: 4px; padding: 4px; font-size: 14px; }
.specs-table { width: 100%; margin-bottom: 8px; font-size: 12px; }
.specs-table td { padding: 2px 4px; }
.spec-key { font-weight: 500; color: var(--text-light); width: 40%; }

/* Stat cards */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card-bg); border-radius: var(--radius); padding: 20px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.stat-card-link { display: block; text-decoration: none; color: inherit; cursor: pointer; }
.stat-card-link:hover { box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.stat-value { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-light); margin-top: 4px; }

/* Order summary */
.order-summary { background: var(--card-bg); border-radius: var(--radius); padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); max-width: 500px; margin: 0 auto 24px; }
.summary-row { display: flex; justify-content: space-between; align-items: center; font-size: 16px; font-weight: 600; margin-bottom: 16px; }

/* Thumb */
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; vertical-align: middle; margin-right: 8px; }

/* Upload area */
.upload-area { border: 2px dashed var(--border); border-radius: var(--radius); padding: 20px; text-align: center; cursor: pointer; min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.upload-area:hover { border-color: var(--primary); }
.upload-preview { max-height: 150px; max-width: 100%; border-radius: 4px; margin-bottom: 8px; }
.upload-placeholder { color: var(--text-light); font-size: 13px; }

/* Lang tabs */
.lang-tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 2px solid var(--border); }
.lang-tab { padding: 8px 20px; border: none; background: none; cursor: pointer; font-size: 14px; color: var(--text-light); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.lang-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.print-header, .print-footer, .print-body { display: none; }

@media print {
  @page { margin: 0; size: A4; }
  body { background: #fff; font-size: 11pt; line-height: 1.5; color: #333; padding: 20mm 20mm 15mm; }
  .sidebar, .mobile-header, .sidebar-footer, .hamburger, .sidebar-footer .language-selector, form[action*="logout"], .btn, .btn-primary, .btn-danger, .form-actions, .card, h3, .table, .badge, .thumb, .page-header { display: none !important; }
  .app-layout { display: block !important; }
  .main-content { margin: 0 !important; padding: 0 !important; width: auto !important; }

  .print-header { display: flex !important; align-items: center; border-bottom: 2px solid #999; padding-bottom: 12px; margin-bottom: 16px; }
  .print-title { font-size: 16pt; font-weight: 700; color: #333; flex: 1; }
  .print-subtitle { font-size: 12pt; font-weight: 600; color: #555; margin-right: 16px; }
  .print-status { font-size: 9pt; font-weight: 700; padding: 3px 12px; border-radius: 4px; }
  .print-status.pending { background: #fff3cd; color: #856404; }
  .print-status.processing { background: #cce5ff; color: #004085; }
  .print-status.completed { background: #d4edda; color: #155724; }
  .print-status.cancelled { background: #f8d7da; color: #721c24; }

  .print-body { display: block !important; }
  .print-info-box { border: 1px solid #000; padding: 10px 14px; margin-bottom: 8px; page-break-inside: avoid; }
  .print-info-row { padding: 3px 0; border: none; }
  .print-info-label { font-weight: 500; color: #888; }
  .print-info-value { margin-left: 8px; }
  .print-section-title { font-size: 12pt; font-weight: 700; margin: 0 0 10px; color: #333; }
  .print-items-table { width: 100%; border-collapse: collapse; font-size: 10pt; }
  .print-items-table thead { border-bottom: 1px solid #000; }
  .print-items-table th { font-weight: 600; padding: 4px 8px; text-align: left; border: none; }
  .print-items-table th:first-child, .print-items-table td:first-child { padding-left: 0; }
  .print-items-table th:last-child, .print-items-table td:last-child { text-align: right; padding-right: 0; }
  .print-items-table td { padding: 4px 8px; border: none; }
  .print-items-table tbody tr:last-child td { border: none; }
  .print-total { border-top: 1px solid #000; text-align: right; font-weight: 700; font-size: 11pt; padding-top: 6px; }

  a { color: #333; text-decoration: none; }
}
