/* ==============================================
   CHIPTUNING PANEL — Main Stylesheet
   Dark Industrial Theme · Orange Accent
   ============================================== */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:        #0d1117;
  --surface:   #161b27;
  --card:      #1c2333;
  --border:    #2d3748;
  --accent:    #f97316;
  --accent-h:  #ea6c0a;
  --text:      #e2e8f0;
  --muted:     #8892a4;
  --success:   #22c55e;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --info:      #3b82f6;
  --sidebar-w: 240px;
  --radius:    8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }

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

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .brand {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-logo .brand-icon {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.sidebar-logo .role-tag {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 10px 4px;
  margin-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 400;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(249,115,22,.08);
  color: var(--text);
}

.nav-item.active {
  background: rgba(249,115,22,.15);
  color: var(--accent);
  font-weight: 500;
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  opacity: .7;
  flex-shrink: 0;
}

.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}

/* ---- MAIN CONTENT ---- */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.user-avatar {
  width: 30px; height: 30px;
  background: rgba(249,115,22,.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.content {
  padding: 24px;
  flex: 1;
}

/* ---- CARDS ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ---- STAT CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity .2s;
}

.stat-card:hover::before { opacity: 1; }

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
}

.stat-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}

.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning .stat-value { color: var(--warning); }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead tr {
  border-bottom: 1px solid var(--border);
}

th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(45,55,72,.5);
  vertical-align: middle;
  color: var(--text);
}

tbody tr:hover { background: rgba(255,255,255,.02); }
tbody tr:last-child td { border-bottom: none; }

.mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* ---- BADGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .3px;
}

.badge-warning  { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-info     { background: rgba(59,130,246,.15);  color: var(--info); }
.badge-success  { background: rgba(34,197,94,.15);   color: var(--success); }
.badge-danger   { background: rgba(239,68,68,.15);   color: var(--danger); }
.badge-secondary{ background: rgba(136,146,164,.12); color: var(--muted); }
.badge-accent   { background: rgba(249,115,22,.15);  color: var(--accent); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-h);
  border-color: var(--accent-h);
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover { background: rgba(255,255,255,.05); color: var(--text); }

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-danger-outline { background: transparent; color: var(--danger); border-color: rgba(239,68,68,.3); }
.btn-danger-outline:hover { background: rgba(239,68,68,.08); }
.btn-success-outline { background: transparent; color: var(--success); border-color: rgba(34,197,94,.3); }
.btn-success-outline:hover { background: rgba(34,197,94,.08); }

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

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color .15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249,115,22,.1);
}

select option { background: var(--card); }
textarea { resize: vertical; min-height: 80px; }

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

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

/* ---- FILE UPLOAD ---- */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}

.file-drop:hover, .file-drop.drag-over {
  border-color: var(--accent);
  background: rgba(249,115,22,.04);
}

.file-drop-icon { font-size: 28px; margin-bottom: 8px; opacity: .5; }
.file-drop p { font-size: 13px; color: var(--muted); margin: 0; }
.file-drop strong { color: var(--accent); }
.file-drop input[type="file"] { display: none; }

/* ---- ALERTS ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success { background: rgba(34,197,94,.1);  border: 1px solid rgba(34,197,94,.25);  color: #4ade80; }
.alert-danger  { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.25);  color: #f87171; }
.alert-warning { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.25); color: #fbbf24; }
.alert-info    { background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.25); color: #60a5fa; }

/* ---- LOGIN PAGE ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .icon-wrap {
  width: 52px; height: 52px;
  background: var(--accent);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  margin: 0 auto 12px;
}

.login-logo h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.login-logo p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* ---- ORDER DETAIL ---- */
.order-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.meta-item label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  display: block;
  margin-bottom: 3px;
}

.meta-item span {
  font-size: 13.5px;
  color: var(--text);
}

/* ---- CREDIT PILL ---- */
.credit-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(249,115,22,.12);
  color: var(--accent);
  border-radius: 20px;
  padding: 3px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 500;
}

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 36px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ---- UTILS ---- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
