/* style.css */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --primary: #1e40af;
  --primary-h: #1d4ed8;
  --success: #15803d;
  --danger: #b91c1c;
  --warn: #b45309;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.topbar {
  background: #0f172a;
  color: #fff;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  font-weight: 700;
  font-size: 16px;
  padding: 12px 0;
  letter-spacing: 0.3px;
}
.nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 6px 0;
}
.nav button {
  background: transparent;
  color: #cbd5e1;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.nav button:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav button.active { background: var(--primary); color: #fff; }

.container {
  max-width: 1280px;
  margin: 16px auto;
  padding: 0 14px 40px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.card h2, .card h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

.stat-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.stat-val { font-size: 22px; font-weight: 700; margin-top: 4px; }

.progress-wrap {
  background: #e5e7eb;
  border-radius: 99px;
  height: 14px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-bar {
  height: 100%;
  background: var(--success);
  transition: width 0.3s;
}
.progress-bar.warn { background: var(--warn); }
.progress-bar.danger { background: var(--danger); }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.field { display: flex; flex-direction: column; gap: 4px; position: relative; }
.field label { font-size: 12px; font-weight: 600; color: #374151; }
input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  background: var(--primary);
  color: #fff;
}
.btn:hover { background: var(--primary-h); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-secondary { background: #4b5563; }
.btn-outline { background: #fff; color: var(--text); border: 1px solid #d1d5db; }
.btn-sm { padding: 5px 9px; font-size: 12px; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
th { background: #f8fafc; font-weight: 600; color: #374151; white-space: nowrap; }
tr:hover td { background: #f9fafb; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.badge-prod { background: #dbeafe; color: #1e40af; }
.badge-serv { background: #f3e8ff; color: #6b21a8; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-err { background: #fee2e2; color: #991b1b; }

.ac-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 40;
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
  display: none;
}
.ac-item {
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.ac-item:hover { background: #eff6ff; }

.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  z-index: 100;
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
  display: none;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }

.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.flex-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 12px; }

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 80;
}
.modal-bg.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px;
}

.print-sheet {
  max-width: 820px;
  margin: 20px auto;
  background: #fff;
  padding: 28px;
  border: 1px solid var(--border);
}
.print-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid #111827;
  padding-bottom: 12px;
  margin-bottom: 18px;
}
.print-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 18px;
}
.print-note {
  margin-top: 18px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  font-size: 12px;
}
.no-print { margin-bottom: 14px; }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .print-sheet { border: none; margin: 0; padding: 0; max-width: 100%; }
}
