:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --success: #059669;
  --success-hover: #047857;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.topbar h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
}

main {
  /* max-width: 960px; */
  margin: 12px auto;
  padding: 0 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-narrow {
  max-width: 400px;
  margin: 60px auto;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 600;
}

.hint {
  color: var(--text-muted);
  font-size: 14px;
  margin: 4px 0 16px;
}

form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 500;
  font-size: 14px;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="date"] {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafafa;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  background: var(--surface);
}

.date-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.date-row label {
  flex: 1;
}

.date-arrow {
  padding-bottom: 10px;
  color: var(--text-muted);
}

.period-form {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

.period-form .date-row {
  flex: 1;
  min-width: 260px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s, transform 0.05s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg);
  color: var(--text);
}

.error {
  color: var(--danger);
  background: var(--danger-soft);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
}

.hidden {
  display: none !important;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.invoices-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.invoices-header h2 {
  margin: 0;
}

.badge {
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
}

.filter-row {
  display: flex;
  gap: 12px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.filter-row input {
  flex: 1;
  min-width: 220px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 12px 10px;
  font-size: 14px;
}

thead th {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.col-expand {
  width: 28px;
}

tbody tr.invoice-row {
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.1s;
}

tbody tr.invoice-row:hover {
  background: #fafafa;
}

.expand-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: transform 0.15s;
}

tr.expanded .expand-icon {
  transform: rotate(90deg);
  color: var(--primary);
}

.detail-row td {
  padding: 0;
  border-bottom: 1px solid var(--border);
}

.detail-inner {
  background: #fafafb;
  padding: 16px 16px 20px 46px;
}

.detail-inner table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.detail-inner thead th {
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
}

.detail-inner td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.detail-inner tr:last-child td {
  border-bottom: none;
}

.qty-empty {
  color: #cbd5e1;
}

.btn-picking {
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-picking:hover {
  background: var(--success-hover);
}

.actions-cell {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-picking-ttk {
  background: var(--primary);
}

.btn-picking-ttk:hover {
  background: var(--primary-hover);
}
