/* Base variables */
:root {
  --bg: #0f1115;
  --panel: #151922;
  --muted: #8b93a7;
  --text: #e6e9f0;
  --primary: #4f7dff;
  --primary-600: #3b68ea;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0,0,0,0.25);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 800px at 10% -10%, rgba(79,125,255,0.08), transparent 40%),
              radial-gradient(1000px 600px at 100% 0%, rgba(34,197,94,0.08), transparent 40%),
              var(--bg);
  color: var(--text);
}

#app { display: grid; grid-template-columns: 260px 1fr; height: 100%; position: relative; }

.sidebar {
  background: linear-gradient(180deg, #0e1220 0%, #0b0f19 100%);
  border-right: 1px solid rgba(255,255,255,0.06);
  padding: 20px 16px;
}
.brand { display:flex; align-items:center; gap:8px; font-weight: 800; letter-spacing: 0.6px; }
.brand-logo { height: 28px; width:auto; }
.brand-text { font-weight: 800; }
.menu { margin-top: 16px; display: grid; gap: 8px; }
.menu-item {
  appearance: none; border: 0; text-align: left;
  padding: 12px 14px; border-radius: 10px; color: var(--text);
  background: transparent; cursor: pointer; font-weight: 500;
}
.menu-item:hover, .menu-item.active {
  background: rgba(79,125,255,0.12);
}

.content { padding: 20px; overflow: auto; }
.topbar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.topbrand { display:flex; align-items:center; gap:8px; font-weight:700; }
.hamburger { display:none; background:transparent; border:1px solid rgba(255,255,255,0.15); color:var(--text); border-radius:8px; padding:8px 10px; cursor:pointer; }
.topbar .search { flex: 1; }
.topbar input[type="search"] {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.08);
  background: #0c1018; color: var(--text);
}

.btn { padding: 10px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.08); background: #0c1018; color: var(--text); cursor: pointer; }
.btn:hover { filter: brightness(1.1); }
.btn-primary { background: linear-gradient(180deg, var(--primary), var(--primary-600)); border: 0; color: white; }
.btn-danger { background: linear-gradient(180deg, #f87171, #ef4444); border: 0; color: white; }
.btn-ghost { background: transparent; border: 1px dashed rgba(255,255,255,0.15); }

.view { display: grid; gap: 16px; }

/* Cards and panels */
.panel { background: linear-gradient(180deg, #121726, #0d1321); border: 1px solid rgba(255,255,255,0.06); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-header { padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,0.06); font-weight: 600; }
.panel-body { padding: 16px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.card {
  background: linear-gradient(160deg, rgba(255,255,255,0.04), transparent);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 24px; font-weight: 700; margin-top: 6px; }

/* Forms */
.form { display: grid; gap: 16px; }
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }

.field { display: grid; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea, .field datalist {
  background: #0c1018; color: var(--text); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px; padding: 10px 12px; width: 100%;
}
.field textarea { min-height: 80px; resize: vertical; }
.help { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }

/* Table */
.table { width: 100%; border-collapse: collapse; overflow: hidden; border-radius: 12px; }
.panel-body { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; overflow: hidden; border-radius: 12px; min-width: 920px; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.06); text-align: left; white-space: normal; word-break: break-word; }
.table th { color: var(--muted); font-weight: 600; background: rgba(255,255,255,0.02); }
.table tbody tr:hover { background: rgba(255,255,255,0.04); }

.status { padding: 4px 8px; border-radius: 999px; font-size: 12px; border: 1px solid rgba(255,255,255,0.1); white-space: normal; line-height: 1.1; max-width: 84px; display: inline-block; text-align: center; }
.status.aberta { background: rgba(79,125,255,0.12); border-color: rgba(79,125,255,0.35); }
.status.analise { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.35); }
.status.peca { background: rgba(255,255,255,0.08); }
.status.concluida { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.35); }
.status.entregue { background: rgba(255,255,255,0.08); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Parts chips */
.parts { display: grid; gap: 8px; }
.parts .adder { display:flex; gap:8px; flex-wrap:wrap; }
.parts .adder input { max-width: 260px; }
.chip { display:flex; align-items:center; gap:8px; padding:8px 10px; border-radius:10px; background: rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.08); }
.chip .title { font-weight:600; }
.chip .price { margin-left:auto; }
.chip .remove, .chip .toggle { background:transparent; border:0; color:#fff; opacity:.9; cursor:pointer; }
.chip.done { background: rgba(34,197,94,0.18); border-color: rgba(34,197,94,0.35); }
.chip.done .title { text-decoration: line-through; opacity: .9; }

/* Badges and tags */
.badge { padding: 2px 8px; border-radius: 999px; font-size: 11px; background: rgba(255,255,255,0.08); color: var(--muted); }

/* Print styles */
@media print {
  .sidebar, .topbar, .toolbar, #btnNewOS { display: none !important; }
  body { background: white; color: black; }
  .panel, .card { box-shadow: none; border: 1px solid #ddd; }
  /* Warranty: remove input borders while printing */
  .doc input, .doc select, .doc textarea {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0 !important;
    -webkit-appearance: none;
    appearance: none;
  }
}

/* Responsive */
/* Mobile menu/backdrop */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 40; display: none; pointer-events: none; }
.backdrop[hidden] { display: none !important; }
.sidebar.open ~ .backdrop { display: block; pointer-events: auto; }

@media (max-width: 1200px) {
  .cards { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 960px) {
  #app { grid-template-columns: 1fr; }
  .hamburger { display:inline-flex; }
  .topbrand { display:flex; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .cards { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .content { padding: 14px; }
}
@media (max-width: 640px) {
  .cards { grid-template-columns: 1fr; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .content { padding: 12px; }
  .topbar { gap: 8px; }
  .topbar .actions { display:flex; }
  .panel-body { padding: 12px; }
  /* Stack table into cards */
  .table.stack { min-width: 0; border-radius: 10px; }
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.06); border-radius: 10px; margin-bottom: 10px; }
  .table.stack td { border: 0; border-bottom: 1px solid rgba(255,255,255,0.06); padding: 10px 12px; display:flex; justify-content: space-between; gap: 10px; }
  .table.stack td:last-child { border-bottom: 0; }
  .table.stack td::before { content: attr(data-label); color: var(--muted); font-weight: 600; }
  .table.stack td .toolbar { justify-content: flex-end; }
}

/* Warranty document */
.doc {
  background: white; color: #111; padding: 24px; border-radius: 12px;
}
.doc header { display:flex; align-items:center; justify-content:space-between; margin-bottom: 12px; }
.doc .logo { height: 48px; }
.doc h1 { font-size: 20px; margin: 8px 0 12px; }
.doc .meta { font-size: 12px; color: #333; margin-bottom: 12px; }
.doc .box { border: 1px solid #ccc; border-radius: 8px; padding: 12px; margin: 10px 0; }
.doc .list { font-size: 13px; line-height: 1.4; }
.doc .list li { margin: 6px 0; }
.doc .rowline { display:flex; gap:12px; flex-wrap:wrap; margin: 8px 0; }
.doc .line { border: none; min-width: 180px; flex: 1; padding: 4px 0; }
.doc .label { font-size: 12px; color: #555; }
.doc .sign { display:flex; justify-content:space-between; align-items:end; margin-top: 40px; gap: 24px; }
.doc .sign .slot { flex:1; text-align:center; }
.doc .sign .slot .dash { border-top: 1px solid #333; margin-top: 48px; }
.doc .watermark { font-size: 11px; color:#666; margin-top: 8px; }

@media print {
  .doc { padding: 0; border: 0; }
  .doc .box { page-break-inside: avoid; }
}
