:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --panel-2: #fafafa;
  --text: #111827;
  --muted: #6b7280;
  --line: #d1d5db;
  --line-soft: #e5e7eb;
  --black: #0b0f19;
  --red: #b91c1c;
  --yellow: #b7791f;
  --green: #15803d;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.hidden { display: none !important; }
button, input, select, textarea { font: inherit; }
a { color: inherit; }

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #111827 0%, #374151 100%);
  padding: 24px;
}
.login-card {
  width: 420px;
  background: white;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 34px;
}
.brand-mark, .logo-box {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: var(--black);
  color: white;
  font-weight: 800;
}
.login-card h1 { margin: 18px 0 4px; font-size: 24px; }
.login-card p { margin: 0 0 24px; color: var(--muted); }
.login-card label { display: block; margin-bottom: 16px; font-weight: 700; }
.login-card input { width: 100%; margin-top: 6px; }
.form-error { color: var(--red); margin-top: 12px; min-height: 20px; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  width: 272px;
  background: #111827;
  color: #f9fafb;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid #030712;
}
.sidebar-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-head span { display: block; font-size: 12px; color: #9ca3af; margin-top: 3px; }
.logo-box { background: white; color: #111827; }
.nav { padding: 14px 10px; display: grid; gap: 7px; }
.nav-btn {
  width: 100%;
  text-align: left;
  color: #d1d5db;
  background: transparent;
  border: 1px solid transparent;
  padding: 12px 14px;
  cursor: pointer;
}
.nav-btn:hover { background: rgba(255,255,255,0.07); color: white; }
.nav-btn.active { background: white; color: #111827; border-color: white; font-weight: 700; }
.sidebar-foot { margin-top: auto; padding: 14px; border-top: 1px solid rgba(255,255,255,0.1); }

.main { flex: 1; min-width: 0; }
.topbar {
  background: white;
  border-bottom: 1px solid var(--line-soft);
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 { margin: 0; font-size: 23px; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.global-search { width: 340px; }
.content { padding: 24px; }

.btn {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  padding: 9px 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
}
.btn:hover { filter: brightness(0.97); }
.btn.primary { background: #111827; color: white; border-color: #111827; font-weight: 700; }
.btn.danger { background: var(--red); color: white; border-color: var(--red); }
.btn.ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,0.22); }
.btn.small { padding: 5px 8px; min-height: 29px; font-size: 12px; }
.btn.full { width: 100%; }
.btn.link { border: none; padding: 0; min-height: auto; background: transparent; text-decoration: underline; }

input, select, textarea {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  padding: 9px 10px;
  width: 100%;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #111827; box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.08); }
textarea { resize: vertical; }
label { font-size: 12px; font-weight: 700; color: #374151; }

.grid { display: grid; gap: 16px; }
.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)); }
.panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}
.panel.pad { padding: 18px; }
.panel-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.panel-head h2, .panel-head h3 { margin: 0; font-size: 16px; }
.panel-body { padding: 16px; }
.card-number { font-size: 32px; font-weight: 800; margin-top: 8px; }
.muted { color: var(--muted); }
.small-muted { color: var(--muted); font-size: 12px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}
.field { display: grid; gap: 6px; }
.col-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; }
.inline-form { display: grid; gap: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; margin-bottom: 16px; }
.inline-form .wide { grid-column: span 2; }
.inline-form .full-line { grid-column: 1 / -1; }

.table-wrap { overflow: auto; border-top: 1px solid var(--line-soft); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
th { background: #f9fafb; color: #374151; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f9fafb; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 8px; border: 1px solid var(--line); background: #fff; }
.status:before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #6b7280; }
.status.red:before { background: var(--red); }
.status.yellow:before { background: var(--yellow); }
.status.green:before { background: var(--green); }
.status.black:before { background: #111827; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { border: 1px solid var(--line); background: #f9fafb; padding: 4px 7px; font-size: 12px; font-weight: 700; }
.badge.final { background: #dcfce7; border-color: #86efac; color: #166534; }
.badge.warn { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.badge.danger { background: #fee2e2; border-color: #fecaca; color: #991b1b; }

.filters { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 10px; align-items: end; padding: 16px; }
.customer-title-row { display: flex; justify-content: space-between; gap: 16px; align-items: start; margin-bottom: 16px; }
.customer-title-row h2 { margin: 0 0 6px; font-size: 26px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line-soft); margin-bottom: 16px; overflow-x: auto; }
.tab-btn { border: 1px solid transparent; border-bottom: none; background: transparent; padding: 10px 12px; cursor: pointer; font-weight: 700; color: #374151; }
.tab-btn.active { background: white; border-color: var(--line-soft); color: #111827; }
.detail-body { min-height: 460px; }

.list { display: grid; gap: 10px; }
.list-item {
  padding: 12px;
  border: 1px solid var(--line-soft);
  background: white;
  display: grid;
  gap: 4px;
}
.list-item.row { grid-template-columns: 1fr auto; align-items: center; }
.timeline { display: grid; gap: 9px; }
.timeline-item { border-left: 3px solid #111827; padding-left: 12px; }
.timeline-title { font-weight: 800; }
.note-text { white-space: pre-wrap; }

.toast {
  position: fixed;
  right: 20px;
  top: 84px;
  background: #111827;
  color: white;
  padding: 12px 14px;
  z-index: 20;
  box-shadow: var(--shadow);
  max-width: 430px;
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  background: #fff;
}

@media (max-width: 980px) {
  .sidebar { width: 220px; }
  .topbar { align-items: stretch; flex-direction: column; }
  .top-actions, .global-search { width: 100%; }
  .filters, .form-grid, .grid.cols-2, .grid.cols-3, .grid.cols-4, .inline-form { grid-template-columns: 1fr; }
  .col-2, .inline-form .wide { grid-column: auto; }
}
