* { margin:0; padding:0; box-sizing:border-box; }
body { font-family:'Segoe UI',system-ui,sans-serif; background:#f1f5f9; color:#1e293b; }
[x-cloak] { display:none!important; }

/* ── Sidebar ── */
.sidebar {
  width:240px; min-height:100vh; background:linear-gradient(180deg,#0f172a 0%,#1e1b4b 100%);
  display:flex; flex-direction:column; flex-shrink:0; position:fixed; left:0; top:0; bottom:0; z-index:40;
  box-shadow:4px 0 24px rgba(0,0,0,.4); transition:transform .25s ease;
}
.sidebar-logo { padding:20px 20px 16px; border-bottom:1px solid rgba(255,255,255,.08); }
.logo-icon { width:42px; height:42px; background:linear-gradient(135deg,#f59e0b,#d97706); border-radius:12px; display:flex; align-items:center; justify-content:center; font-size:18px; color:#fff; box-shadow:0 4px 12px rgba(245,158,11,.4); }
.logo-text { font-size:14px; font-weight:700; color:#fff; margin-top:2px; }
.logo-sub  { font-size:11px; color:#64748b; }
.nav-section { padding:12px 12px; flex:1; overflow-y:auto; }
.nav-label { font-size:10px; font-weight:600; color:#475569; text-transform:uppercase; letter-spacing:.08em; padding:8px 8px 4px; }
.nav-item {
  display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:10px;
  color:#94a3b8; font-size:13px; font-weight:500; cursor:pointer; transition:all .15s;
  width:100%; border:none; background:none; text-align:left; margin-bottom:2px;
}
.nav-item:hover { background:rgba(255,255,255,.07); color:#e2e8f0; }
.nav-item.active { background:linear-gradient(135deg,#f59e0b,#d97706); color:#fff; box-shadow:0 4px 12px rgba(245,158,11,.35); font-weight:600; }
.nav-item .nav-icon { width:18px; text-align:center; font-size:14px; }
.nav-badge { margin-left:auto; background:rgba(239,68,68,.2); color:#f87171; font-size:10px; padding:1px 7px; border-radius:20px; font-weight:600; }
.sidebar-user { padding:14px 16px; border-top:1px solid rgba(255,255,255,.08); }
.user-avatar { width:34px; height:34px; border-radius:50%; background:linear-gradient(135deg,#f59e0b,#d97706); display:flex; align-items:center; justify-content:center; font-weight:700; color:#fff; font-size:13px; }

/* ── Layout ── */
.main-wrap { margin-left:240px; min-height:100vh; display:flex; flex-direction:column; }
.topbar { background:#fff; border-bottom:1px solid #e2e8f0; padding:14px 28px; display:flex; align-items:center; justify-content:space-between; position:sticky; top:0; z-index:30; box-shadow:0 1px 8px rgba(0,0,0,.04); gap:12px; }
.page-content { padding:28px; flex:1; }
.hamburger { display:none; align-items:center; justify-content:center; width:36px; height:36px; border-radius:8px; background:#f1f5f9; border:none; cursor:pointer; color:#475569; font-size:16px; flex-shrink:0; }
.sidebar-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:39; }

/* ── Cards ── */
.card { background:#fff; border-radius:16px; box-shadow:0 2px 12px rgba(0,0,0,.06); padding:24px; border:1px solid #f1f5f9; }
.stat-card { background:#fff; border-radius:16px; padding:20px; border:1px solid #f1f5f9; box-shadow:0 2px 12px rgba(0,0,0,.06); transition:transform .2s,box-shadow .2s; }
.stat-card:hover { transform:translateY(-2px); box-shadow:0 8px 24px rgba(0,0,0,.1); }
.stat-icon { width:48px; height:48px; border-radius:12px; display:flex; align-items:center; justify-content:center; font-size:20px; }
.stat-value { font-size:28px; font-weight:800; color:#0f172a; line-height:1; }
.stat-label { font-size:12px; color:#64748b; margin-top:4px; }

/* ── Buttons ── */
.btn { display:inline-flex; align-items:center; gap:6px; padding:8px 16px; border-radius:10px; font-size:13px; font-weight:600; cursor:pointer; border:none; transition:all .15s; }
.btn-gold { background:linear-gradient(135deg,#f59e0b,#d97706); color:#fff; box-shadow:0 2px 8px rgba(245,158,11,.3); }
.btn-gold:hover { box-shadow:0 4px 16px rgba(245,158,11,.4); transform:translateY(-1px); }
.btn-outline { background:#fff; color:#475569; border:1px solid #e2e8f0; }
.btn-outline:hover { background:#f8fafc; border-color:#cbd5e1; }
.btn-red { background:#fff0f0; color:#ef4444; border:1px solid #fecaca; }
.btn-red:hover { background:#fee2e2; }
.btn-sm { padding:6px 12px; font-size:12px; }
.btn:disabled { opacity:.5; cursor:not-allowed; transform:none!important; }

/* ── Inputs ── */
.inp { width:100%; padding:9px 12px; border:1px solid #e2e8f0; border-radius:10px; font-size:13px; color:#1e293b; background:#fff; transition:border .15s,box-shadow .15s; outline:none; }
.inp:focus { border-color:#f59e0b; box-shadow:0 0 0 3px rgba(245,158,11,.12); }
select.inp { cursor:pointer; }
textarea.inp { resize:none; }

/* ── Table ── */
.tbl { width:100%; border-collapse:collapse; font-size:13px; }
.tbl thead tr { background:#f8fafc; }
.tbl thead th { padding:11px 16px; text-align:left; font-size:11px; font-weight:700; color:#64748b; text-transform:uppercase; letter-spacing:.06em; border-bottom:2px solid #e2e8f0; white-space:nowrap; }
.tbl tbody tr { border-bottom:1px solid #f1f5f9; transition:background .1s; }
.tbl tbody tr:hover { background:#fafbff; }
.tbl tbody td { padding:12px 16px; color:#334155; }
.tbl tbody tr:last-child { border-bottom:none; }

/* ── Badges ── */
.badge { display:inline-flex; align-items:center; padding:3px 10px; border-radius:20px; font-size:11px; font-weight:600; }
.badge-available { background:#dcfce7; color:#16a34a; }
.badge-on_hold   { background:#fef3c7; color:#d97706; }
.badge-sold      { background:#fee2e2; color:#dc2626; }
.badge-pending   { background:#dbeafe; color:#2563eb; }
.badge-confirmed { background:#dcfce7; color:#16a34a; }
.badge-shipped   { background:#ede9fe; color:#7c3aed; }
.badge-cancelled { background:#fee2e2; color:#dc2626; }
.badge-active    { background:#dcfce7; color:#16a34a; }
.badge-inactive  { background:#f1f5f9; color:#64748b; }

/* ── Modal ── */
.overlay { position:fixed; inset:0; background:rgba(15,23,42,.6); backdrop-filter:blur(4px); z-index:100; display:flex; align-items:center; justify-content:center; padding:16px; }
.modal { background:#fff; border-radius:20px; box-shadow:0 24px 64px rgba(0,0,0,.25); width:100%; max-width:520px; max-height:92vh; overflow-y:auto; }
.modal-lg { max-width:720px; }
.modal-header { padding:20px 24px 16px; border-bottom:1px solid #f1f5f9; display:flex; align-items:center; justify-content:space-between; }
.modal-header h3 { font-size:16px; font-weight:700; color:#0f172a; }
.modal-body { padding:24px; }
.modal-footer { padding:16px 24px; border-top:1px solid #f1f5f9; display:flex; justify-content:flex-end; gap:10px; }
.close-btn { width:30px; height:30px; border-radius:8px; background:#f1f5f9; border:none; cursor:pointer; color:#64748b; display:flex; align-items:center; justify-content:center; font-size:13px; }
.close-btn:hover { background:#e2e8f0; color:#1e293b; }

/* ── Toggle ── */
.toggle { position:relative; width:40px; height:22px; cursor:pointer; flex-shrink:0; }
.toggle input { opacity:0; width:0; height:0; position:absolute; }
.toggle-track { position:absolute; inset:0; border-radius:11px; background:#e2e8f0; transition:background .2s; }
.toggle input:checked + .toggle-track { background:linear-gradient(135deg,#f59e0b,#d97706); }
.toggle-thumb { position:absolute; top:3px; left:3px; width:16px; height:16px; background:#fff; border-radius:50%; transition:transform .2s; box-shadow:0 1px 4px rgba(0,0,0,.2); }
.toggle input:checked ~ .toggle-thumb { transform:translateX(18px); }

/* ── Progress bar ── */
.progress-track { height:6px; background:#f1f5f9; border-radius:3px; overflow:hidden; }
.progress-fill { height:100%; background:linear-gradient(90deg,#f59e0b,#d97706); border-radius:3px; transition:width .6s ease; }

/* ── Login ── */
.login-bg { min-height:100vh; background:linear-gradient(135deg,#0f172a 0%,#1e1b4b 50%,#0f172a 100%); display:flex; align-items:center; justify-content:center; padding:20px; }
.login-card { background:#fff; border-radius:24px; padding:40px; width:100%; max-width:420px; box-shadow:0 32px 80px rgba(0,0,0,.5); }
.login-icon { width:60px; height:60px; background:linear-gradient(135deg,#f59e0b,#d97706); border-radius:16px; display:flex; align-items:center; justify-content:center; font-size:24px; color:#fff; margin:0 auto 20px; box-shadow:0 8px 24px rgba(245,158,11,.4); }

/* ── Toast ── */
.toast { position:fixed; top:20px; right:20px; z-index:200; padding:12px 18px; border-radius:12px; font-size:13px; font-weight:600; display:flex; align-items:center; gap:8px; box-shadow:0 8px 24px rgba(0,0,0,.15); animation:slideIn .3s ease; }
.toast-success { background:#fff; color:#16a34a; border-left:4px solid #16a34a; }
.toast-error   { background:#fff; color:#dc2626; border-left:4px solid #dc2626; }
@keyframes slideIn { from{transform:translateX(100%);opacity:0} to{transform:translateX(0);opacity:1} }

/* ── Company card ── */
.company-card { background:#fff; border-radius:16px; border:1px solid #f1f5f9; padding:20px; box-shadow:0 2px 12px rgba(0,0,0,.05); transition:all .2s; }
.company-card:hover { box-shadow:0 8px 24px rgba(0,0,0,.1); transform:translateY(-2px); }
.company-avatar { width:48px; height:48px; border-radius:14px; background:linear-gradient(135deg,#1e1b4b,#312e81); display:flex; align-items:center; justify-content:center; color:#f59e0b; font-weight:800; font-size:20px; }

/* ── Field toggle card ── */
.field-card { padding:14px; border-radius:12px; border:1px solid #e2e8f0; transition:all .2s; }
.field-card.enabled { border-color:#f59e0b; background:linear-gradient(135deg,#fffbeb,#fff); }

/* ── Misc ── */
.order-amount { font-size:14px; font-weight:700; color:#0f172a; }
::-webkit-scrollbar { width:5px; height:5px; }
::-webkit-scrollbar-track { background:#f8fafc; }
::-webkit-scrollbar-thumb { background:#cbd5e1; border-radius:10px; }
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.grid-3 { display:grid; grid-template-columns:repeat(3,1fr); gap:16px; }
.grid-4 { display:grid; grid-template-columns:repeat(4,1fr); gap:16px; }
.col-span-2 { grid-column:span 2; }
@media(max-width:1100px){.grid-4{grid-template-columns:repeat(2,1fr);}}
@media(max-width:700px){.grid-2,.grid-3,.grid-4{grid-template-columns:1fr;}}

/* ── Responsive ── */
@media(max-width:768px){
  /* Sidebar: hidden off-screen, slides in */
  .sidebar { transform:translateX(-100%); }
  .sidebar.open { transform:translateX(0); }
  .sidebar-overlay.open { display:block; }
  .hamburger { display:flex; }

  /* Main layout */
  .main-wrap { margin-left:0; }
  .topbar { padding:10px 14px; flex-wrap:wrap; gap:8px; }
  .topbar > div:first-child { flex:1; min-width:0; }
  .topbar > div:last-child { display:flex; flex-wrap:wrap; gap:6px; }
  .page-content { padding:14px; }

  /* Cards */
  .card { padding:14px; border-radius:12px; }
  .stat-card { padding:14px; }
  .stat-value { font-size:22px; }

  /* Tables: horizontal scroll already on, shrink padding */
  .tbl thead th { padding:8px 10px; font-size:10px; }
  .tbl tbody td { padding:8px 10px; font-size:12px; }

  /* Modals: full-width on mobile */
  .overlay { padding:0; align-items:flex-end; }
  .modal { border-radius:20px 20px 0 0; max-height:92vh; max-width:100%; }
  .modal-lg { max-width:100%; }
  .modal-body { padding:16px; }
  .modal-header { padding:14px 16px 12px; }
  .modal-footer { padding:12px 16px; }

  /* Toolbar wraps */
  .toolbar { gap:6px; }
  .toolbar input.inp { width:160px !important; }

  /* Diamond media viewer: stack vertically */
  .modal.modal-lg > div[style*="display:flex;flex:1"] { flex-direction:column !important; }

  /* Filter tag buttons: smaller */
  .btn-sm { padding:4px 8px; font-size:11px; }

  /* Company cards grid */
  .company-grid { grid-template-columns:1fr !important; }

  /* Hide less important table columns on mobile */
  .tbl .hide-mobile { display:none; }

  /* Login */
  .login-card { padding:28px 20px; }

  /* Page content spacing for stat grids */
  .grid-4 { grid-template-columns:repeat(2,1fr) !important; gap:10px; }
  .grid-3 { grid-template-columns:repeat(2,1fr) !important; gap:10px; }

  /* Diamond detail modal: shorter hero, bottom sheet */
  .diamond-view-overlay { padding:0 !important; align-items:flex-end !important; }
  .diamond-view-modal { border-radius:20px 20px 0 0 !important; max-width:100% !important; max-height:95vh !important; }
  .diamond-view-hero { height:260px !important; }
  .diamond-view-chips { grid-template-columns:repeat(2,1fr) !important; }
  .diamond-view-cols { grid-template-columns:1fr !important; }
}
/* ── Stock filter modal: responsive grid ── */
@media(max-width: 600px) {
  .filter-modal-grid { grid-template-columns: 1fr !important; }
}

/* ── Mobile diamond cards ── */
.stock-table-wrap { display:block; }
.stock-cards      { display:none; }

@media(max-width:768px){
  .stock-table-wrap { display:none; }
  .stock-cards      { display:flex; flex-direction:column; }
  .dcm { display:flex; align-items:center; gap:10px; padding:10px 12px; border-bottom:1px solid #f1f5f9; cursor:pointer; transition:background .12s; }
  .dcm:active { background:#f8fafc; }
  .dcm-thumb { width:46px; height:46px; border-radius:10px; flex-shrink:0; background:#f8fafc; border:1px solid #e2e8f0; display:flex; align-items:center; justify-content:center; overflow:hidden; position:relative; }
  .dcm-thumb img { width:100%; height:100%; object-fit:cover; }
  .dcm-info { flex:1; min-width:0; }
  .dcm-id   { font-family:monospace; font-weight:700; font-size:12px; color:#0f172a; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .dcm-sub  { font-size:11px; color:#64748b; margin-top:1px; }
  .dcm-specs{ font-size:12px; font-weight:600; color:#374151; margin-top:3px; display:flex; gap:6px; flex-wrap:wrap; align-items:center; }
  .dcm-price{ font-weight:800; font-size:14px; color:#0f172a; margin-top:3px; }
  .dcm-actions { display:flex; flex-direction:column; gap:4px; flex-shrink:0; }
}

.divider { height:1px; background:#f1f5f9; margin:16px 0; }
.text-gold { color:#d97706; }
.text-muted { color:#64748b; }
.text-xs { font-size:11px; }
.text-sm { font-size:13px; }
.empty-state { text-align:center; padding:60px 20px; color:#94a3b8; }
.empty-state i { font-size:48px; opacity:.2; margin-bottom:12px; display:block; }
.api-key-box { background:#f8fafc; border:1px solid #e2e8f0; border-radius:10px; padding:12px; font-family:monospace; font-size:12px; color:#1e293b; word-break:break-all; line-height:1.6; }
.section-title { font-size:15px; font-weight:700; color:#0f172a; margin-bottom:16px; display:flex; align-items:center; gap:8px; }
.dot { width:8px; height:8px; border-radius:50%; background:#f59e0b; flex-shrink:0; }
.toolbar { display:flex; flex-wrap:wrap; gap:10px; margin-bottom:20px; align-items:center; }
