/* ===== Design System — Quản lý Vật tư ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-soft: #dbeafe;
  --success: #059669;
  --success-bg: #ecfdf5;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #d97706;

  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow: 0 1px 2px rgba(15,23,42,.05), 0 8px 24px rgba(15,23,42,.06);
  --shadow-lg: 0 12px 40px rgba(15,23,42,.1);
  --header-h: 4rem;

  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --input-h: 2.75rem;
  --btn-h: 2.65rem;
}

html { scroll-behavior: smooth; scrollbar-width: none; }
html::-webkit-scrollbar { display: none; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* ===== Header ===== */
.app-header {
  position: sticky; top: 0; z-index: 200;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(15,23,42,.04);
}

.app-header-inner {
  max-width: 1080px; margin: 0 auto;
  padding: .7rem 1rem;
  display: flex; align-items: center; gap: .75rem;
  min-height: var(--header-h);
}

.app-brand {
  display: flex; align-items: center; gap: .65rem;
  min-width: 0; flex: 0 1 auto; max-width: 220px;
}

.app-brand-mark {
  width: 2.35rem; height: 2.35rem; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: #fff; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.app-brand-mark svg { width: 1.15rem; height: 1.15rem; }

.app-brand-text h1 {
  font-size: 1rem; font-weight: 700; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-brand-sub {
  font-size: .72rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
}
.btn-logout-text { display: none; }
.btn-logout-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  transition: .15s;
}
.btn-logout-icon:hover { color: var(--danger); background: var(--danger-bg); }
.btn-logout-icon svg { width: 1.25rem; height: 1.25rem; }

.app-nav { display: flex; align-items: stretch; gap: .15rem; }
.app-nav .nav-item {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .15rem; padding: .35rem .25rem; border-radius: var(--radius-xs);
  color: var(--text-muted); font-size: .62rem; font-weight: 600;
  transition: .15s; flex: 1;
}
.nav-icon svg { width: 1.15rem; height: 1.15rem; }
.label-short { display: none; }

.app-nav--mobile {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(15,23,42,.07);
  padding: .35rem .15rem calc(.35rem + env(safe-area-inset-bottom, 0px));
}
.app-nav--mobile .nav-item.active { color: var(--primary); background: var(--primary-light); }
.nav-item--admin { opacity: .88; }
.app-nav--desktop { display: none; }

.main-content {
  max-width: 1080px; margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

/* ===== Auth ===== */
.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 1.25rem;
  background: linear-gradient(160deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%);
}
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card {
  background: var(--surface); border-radius: calc(var(--radius) + 4px);
  padding: 2rem 1.75rem; box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo .app-brand-mark { margin: 0 auto .75rem; width: 3rem; height: 3rem; }
.auth-logo h1 { font-size: 1.3rem; margin-bottom: .25rem; }
.auth-logo p { color: var(--text-muted); font-size: .88rem; }
.auth-hint {
  text-align: center; margin-top: 1.15rem;
  font-size: .78rem; color: var(--text-muted);
}
.auth-hint code {
  background: var(--surface-2); padding: .12rem .35rem;
  border-radius: 4px; font-size: .76rem; color: var(--text);
}
.auth-remember {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: .15rem 0 1rem;
  font-size: .875rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.auth-remember input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* ===== Page layout ===== */
.page-header {
  display: flex; flex-wrap: wrap; align-items: flex-start;
  justify-content: space-between; gap: .85rem;
  margin-bottom: 1.15rem;
  padding-left: .85rem;
  border-left: 4px solid var(--primary);
}
.page-title { font-size: 1.3rem; font-weight: 700; line-height: 1.3; }
.page-desc { color: var(--text-muted); font-size: .88rem; margin-top: .15rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card-title {
  font-size: .95rem; font-weight: 700;
  margin-bottom: 1rem; padding-bottom: .7rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.grid-2 { display: grid; gap: 1rem; }

/* ===== Forms ===== */
label {
  display: block;
  font-size: .82rem; font-weight: 600;
  color: var(--text);
  margin-bottom: .4rem;
}
.req { color: var(--danger); }
.optional { font-weight: 500; color: var(--text-muted); font-size: .82rem; }

input, select, textarea {
  width: 100%; height: var(--input-h);
  padding: 0 .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: .92rem; font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: .65rem .85rem; min-height: 5rem; }
select { cursor: pointer; }
input::placeholder { color: #94a3b8; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.input-phone, .input-numeric { font-variant-numeric: tabular-nums; letter-spacing: .03em; }

.field { margin-bottom: .95rem; }
.field-hint { font-size: .74rem; color: var(--text-muted); margin-top: .28rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-stack { display: block; }
.form-section {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.form-section:first-child { padding-top: 0; }
.form-section:last-of-type { border-bottom: none; padding-bottom: 0; }
.form-section-title {
  font-size: .88rem; font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: .85rem;
}
.form-actions {
  padding-top: 1rem;
  display: flex; gap: .65rem; flex-wrap: wrap;
}
.inline-form { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: var(--btn-h);
  padding: 0 1.1rem;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  font-size: .875rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--text-muted); border: none; min-height: auto; padding: .45rem .65rem; }
.btn-sm { min-height: 2.15rem; padding: 0 .75rem; font-size: .8rem; }
.btn-block { width: 100%; }
.btn-icon {
  width: 2.1rem; height: 2.1rem; min-height: 0; padding: 0;
  border: none; border-radius: var(--radius-xs); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.btn-icon svg { width: 1rem; height: 1rem; }
.btn-icon-edit { color: var(--primary); background: var(--primary-light); }
.btn-icon-edit:hover { background: var(--primary-soft); }
.btn-icon-delete { color: var(--danger); background: var(--danger-bg); }
.btn-icon-delete:hover { background: #fee2e2; }
.btn-icon-lock { color: var(--text-muted); background: var(--surface-2); }
.btn-icon-lock:hover { color: var(--warning); background: #fef3c7; }
.btn-danger-icon { color: var(--danger); background: var(--danger-bg); }
.table-actions { display: flex; gap: .35rem; align-items: center; justify-content: flex-end; }

.action-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.15rem; }

/* ===== Table & list ===== */
.table-wrap { overflow-x: auto; margin: 0 -.15rem; padding: 0 .15rem; }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th, .data-table td {
  padding: .7rem .55rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  font-size: .72rem; font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-2);
}
.data-table th:first-child { border-radius: var(--radius-xs) 0 0 0; }
.data-table th:last-child { border-radius: 0 var(--radius-xs) 0 0; }
.data-table tbody tr:hover { background: #fafbfc; }
.data-table tbody tr.row-selected { background: var(--primary-light); }
.col-check {
  width: 2.75rem;
  text-align: center;
  vertical-align: middle;
}
.col-check input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--primary);
  cursor: pointer;
}

.bulk-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
  z-index: 210;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .65rem 1rem;
  max-width: calc(100% - 1.5rem);
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.bulk-bar[hidden] { display: none !important; }
.bulk-bar-close {
  position: absolute;
  top: .35rem;
  right: .45rem;
  width: 1.5rem;
  height: 1.5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.bulk-bar-link {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.bulk-bar-count {
  flex: 1;
  min-width: 8rem;
  font-size: .875rem;
  color: var(--text-muted);
  padding-right: 1.25rem;
}
.bulk-bar .btn-danger { margin-left: auto; }

@media (min-width: 768px) {
  .bulk-bar {
    bottom: 1.5rem;
    flex-wrap: nowrap;
    padding: .85rem 1.15rem;
    padding-right: 2rem;
  }
  .bulk-bar-close { top: 50%; transform: translateY(-50%); }
}

.text-right { text-align: right !important; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .8rem; }
.text-center { text-align: center; }
.money { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--success); }
.total-row td { border-top: 2px solid var(--border); font-weight: 700; }
.total-amount { font-size: 1.05rem; }

.list-items { list-style: none; }
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.empty-inline { color: var(--text-muted); font-size: .88rem; padding: .5rem 0; }

.badge {
  display: inline-block; padding: .18rem .55rem;
  border-radius: 999px; font-size: .72rem; font-weight: 700;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-muted { background: var(--surface-2); color: var(--text-muted); }

.alert {
  padding: .75rem 1rem; border-radius: var(--radius-xs);
  margin-bottom: 1rem; font-size: .875rem;
}
.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }

.empty-state { text-align: center; padding: 2.5rem 1.5rem; }
.empty-state p { color: var(--text-muted); margin: .75rem 0 1.25rem; }

/* ===== Admin owners (mobile cards) ===== */
.admin-mobile-list { display: block; }
.admin-desktop-table { display: block; }
.admin-owner-card {
  padding: .9rem 0;
  border-bottom: 1px solid var(--border);
}
.admin-owner-card:last-child { border-bottom: none; }
.admin-owner-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .65rem;
}
.admin-owner-name {
  font-size: .95rem;
  line-height: 1.35;
}
.admin-owner-meta {
  margin: 0 0 .75rem;
  display: grid;
  gap: .4rem;
}
.admin-owner-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  font-size: .85rem;
}
.admin-owner-row dt {
  color: var(--text-muted);
  flex-shrink: 0;
}
.admin-owner-row dd {
  margin: 0;
  text-align: right;
  word-break: break-word;
}
.admin-owner-actions { margin-top: .15rem; }

@media (min-width: 768px) {
  .admin-mobile-list { display: none !important; }
}
@media (max-width: 767px) {
  .admin-desktop-table { display: none !important; }
}

/* ===== Invoice ===== */
.invoice-page-header { margin-bottom: 1rem; }
.invoice-mobile-title {
  display: none;
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.invoice-toolbar { margin-bottom: 1rem; }
.customer-btn {
  width: 100%;
  justify-content: center;
  min-height: 2.75rem;
}
.customer-summary {
  margin-top: .75rem; padding: .85rem 1rem;
  background: var(--primary-light); border-radius: var(--radius-xs);
  font-size: .875rem; border-left: 3px solid var(--primary);
}
.customer-summary-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: .35rem;
}
.scroll-hint {
  display: none;
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: .5rem;
}
.invoice-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  margin-bottom: .75rem;
}
.invoice-scroll .invoice-table {
  width: max-content;
  min-width: 680px;
}
.invoice-desktop { display: block; }
.invoice-mobile-list { display: block; }
.invoice-item {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  padding: .85rem 0;
  border-bottom: 1px solid var(--border);
}
.invoice-item:last-child { border-bottom: none; }
.invoice-item-num {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: .75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.invoice-item-body { flex: 1; min-width: 0; }
.invoice-item-name {
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: .35rem;
  line-height: 1.35;
}
.invoice-item-calc {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: .2rem;
}
.invoice-item-amount {
  font-weight: 700;
  color: var(--success);
  font-size: .9rem;
}
.invoice-item-actions {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  flex-shrink: 0;
}
.add-line-btn { margin-top: .75rem; width: 100%; }
.col-stt { width: 2.5rem; }
.col-qty { width: 4.5rem; }
.col-price { width: 7rem; }
.col-amount { width: 7.5rem; }
.invoice-table select, .invoice-table input { height: 2.25rem; padding: 0 .45rem; font-size: .85rem; }
.invoice-table .line-qty { width: 4.5rem; min-width: 4rem; text-align: center; }
.invoice-table .line-amount {
  background: var(--surface-2);
  font-weight: 600;
}
.invoice-table td.col-action {
  width: 44px;
  text-align: center;
}
.total-box {
  background: var(--success-bg);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
}
.total-box .label { font-size: .9rem; color: var(--text-muted); }
.total-box .amount {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--success);
}
.invoice-action-row .invoice-action-form { display: contents; }

.mat-picker-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .65rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  font-size: .9rem;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  min-height: var(--input-h);
}
.mat-picker-trigger:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.mat-picker-trigger.placeholder { color: var(--text-muted); }
.mat-picker-arrow {
  font-size: .65rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.modal-summary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: .85rem 1rem;
  margin-bottom: 1rem;
}
.modal-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .875rem;
}
.modal-summary-row .highlight {
  font-weight: 700;
  color: var(--success);
  font-size: 1rem;
}
.bottom-sheet {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: none;
  align-items: flex-end;
}
.bottom-sheet.open { display: flex; }
.bottom-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .45);
}
.bottom-sheet-panel {
  position: relative;
  width: 100%;
  height: 92vh;
  max-height: 92vh;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp .22s ease;
}
.bottom-sheet-panel--form {
  height: auto;
  max-height: 92vh;
}
.bottom-sheet-header {
  display: grid;
  grid-template-columns: 2.5rem 1fr 2.5rem;
  align-items: center;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.bottom-sheet-body {
  padding: 1rem 1rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}
.bottom-sheet-body .modal-actions {
  margin-top: .5rem;
}

/* Đổi mật khẩu: mobile = bottom sheet, desktop = popup giữa */
@media (min-width: 768px) {
  .password-sheet.open {
    align-items: center;
    justify-content: center;
    padding: 1rem;
  }
  .password-sheet .bottom-sheet-panel--form {
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: popupIn .22s ease;
  }
  .password-sheet .bottom-sheet-back {
    display: none;
  }
  .password-sheet .bottom-sheet-header {
    grid-template-columns: 1fr auto;
    justify-items: start;
  }
  .password-sheet .bottom-sheet-header h3 {
    text-align: left;
  }
  .password-sheet .bottom-sheet-header > span:last-child {
    justify-self: end;
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .password-sheet .bottom-sheet-header > span:last-child::before {
    content: '×';
  }
}
@keyframes popupIn {
  from { opacity: 0; transform: scale(.97) translateY(10px); }
  to { opacity: 1; transform: none; }
}

.bottom-sheet-header h3 {
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  padding: 0;
  border: none;
}
.bottom-sheet-back {
  width: 2rem;
  height: 2rem;
  border: none;
  background: transparent;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bottom-sheet-search-wrap {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: .75rem 1rem;
  padding: 0 .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  flex-shrink: 0;
}
.bottom-sheet-search-wrap .search-icon {
  color: var(--text-muted);
  font-size: .95rem;
  flex-shrink: 0;
}
.bottom-sheet-search-wrap input {
  border: none;
  background: transparent;
  flex: 1;
  padding: .7rem 0;
  font-size: .9rem;
}
.bottom-sheet-search-wrap input:focus { outline: none; }
.bottom-sheet-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}
.bottom-sheet-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .95rem 1rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.bottom-sheet-item-text {
  flex: 1;
  min-width: 0;
  font-size: .9rem;
  line-height: 1.35;
  word-break: break-word;
}
.bottom-sheet-item-sub {
  display: block;
  font-size: .8rem;
  color: var(--primary);
  font-weight: 600;
  margin-top: .15rem;
}
.mat-radio {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  flex-shrink: 0;
  position: relative;
}
.bottom-sheet-item.selected .mat-radio {
  background: #facc15;
  border-color: #facc15;
}
.bottom-sheet-item.selected .mat-radio::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: #1e293b;
}
.bottom-sheet-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: .875rem;
}

@media (max-width: 600px) {
  .invoice-page-header { display: none; }
  .invoice-mobile-title { display: block; }
  .invoice-desktop { display: none !important; }
  #invoice-lines .empty-inline {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--text-muted);
    font-size: .875rem;
  }
  .total-box .amount { font-size: 1.5rem; }
  .invoice-action-row {
    flex-direction: column;
    gap: .6rem;
  }
  .invoice-action-row .btn { width: 100%; justify-content: center; }
}

@media (min-width: 601px) {
  .invoice-mobile-list { display: none !important; }
  .invoice-scroll {
    overflow-x: visible;
    width: 100%;
  }
  .invoice-scroll .invoice-table {
    width: 100%;
    min-width: 100%;
    table-layout: fixed;
  }
  .invoice-table .col-stt { width: 5%; }
  .invoice-table .col-material { width: 38%; }
  .invoice-table .col-qty { width: 10%; }
  .invoice-table .col-price { width: 16%; }
  .invoice-table .col-amount { width: 18%; }
  .invoice-table .col-action { width: 4.5rem; }
  .invoice-table select.line-material,
  .invoice-table .line-qty,
  .invoice-table .line-price {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
  .invoice-table td.col-amount,
  .invoice-table th.col-amount {
    text-align: right;
  }
  .invoice-table th.col-qty,
  .invoice-table th.col-price,
  .invoice-table td.col-qty,
  .invoice-table td.col-price {
    text-align: center;
  }
  .invoice-table td.col-qty .line-qty {
    text-align: center;
  }
  .invoice-table td.col-price .line-price {
    text-align: right;
  }
}

.invoice-sheet-card .shop-name { font-weight: 700; font-size: 1.05rem; }
.invoice-title { font-size: 1.2rem; font-weight: 800; letter-spacing: .06em; margin: 1rem 0 .5rem; }
.invoice-customer {
  background: var(--surface-2); padding: .85rem 1rem;
  border-radius: var(--radius-xs); margin: 1rem 0; font-size: .875rem;
}

.qr-preview, .invoice-qr { margin-top: 1.25rem; text-align: center; }
.bank-transfer-info {
  margin-top: 1.25rem;
  padding: 1rem 1.1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: .875rem;
}
.bank-transfer-title {
  font-weight: 700;
  margin-bottom: .65rem;
  font-size: .9rem;
}
.bank-transfer-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .35rem 0;
  border-bottom: 1px dashed var(--border);
}
.bank-transfer-row:last-of-type { border-bottom: none; }
.bank-transfer-row span { color: var(--text-muted); flex-shrink: 0; }
.bank-transfer-row strong { text-align: right; word-break: break-word; }
.bank-transfer-note {
  margin-top: .75rem;
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.qr-img {
  width: 200px; max-width: 100%;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  cursor: pointer;
}
.qr-img-lg { width: 100%; max-width: 280px; border-radius: var(--radius-sm); }

/* ===== Modal ===== */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: flex-end; justify-content: center;
}
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.45); }
.modal-sheet {
  position: relative; width: 100%; max-width: 420px;
  background: var(--surface); border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.25rem 1rem 1.5rem;
  box-shadow: var(--shadow-lg);
  animation: slideUp .22s ease;
}
.modal-sheet h3 {
  font-size: 1rem; font-weight: 700;
  margin-bottom: 1rem; padding-bottom: .7rem;
  border-bottom: 1px solid var(--border);
}
.modal-actions { display: flex; gap: .5rem; margin-top: 1rem; }
.modal-actions .btn { flex: 1; }

.confirm-modal {
  align-items: center;
  padding: 1rem;
  z-index: 1100;
}
.confirm-modal .modal-sheet {
  border-radius: var(--radius);
  text-align: center;
  padding: 1.5rem 1.25rem 1.25rem;
  animation: confirmIn .22s ease;
}
.confirm-modal h3 {
  border: none;
  padding: 0;
  margin-bottom: .45rem;
  font-size: 1.05rem;
}
.confirm-icon {
  width: 3.25rem;
  height: 3.25rem;
  margin: 0 auto .85rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.confirm-icon--danger {
  background: var(--danger-bg);
  color: var(--danger);
}
.confirm-icon svg { width: 1.4rem; height: 1.4rem; }
.confirm-message {
  margin: 0;
  color: var(--text-muted);
  font-size: .9rem;
  line-height: 1.55;
}
@keyframes confirmIn {
  from { opacity: 0; transform: scale(.97) translateY(8px); }
  to { opacity: 1; transform: none; }
}

.qr-modal { align-items: center; padding: 1rem; }
.qr-modal .modal-sheet { border-radius: var(--radius); text-align: center; }
.qr-modal .qr-modal-close { margin-top: .85rem; }

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.toast {
  position: fixed; bottom: calc(5rem + env(safe-area-inset-bottom, 0px)); left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1e293b; color: #fff;
  padding: .6rem 1.15rem; border-radius: 999px;
  font-size: .84rem; opacity: 0; pointer-events: none;
  transition: .22s; z-index: 3000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Desktop ===== */
@media (min-width: 768px) {
  body { padding-bottom: 0; }

  .app-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
    border-bottom: none;
  }
  .app-header-inner { padding: .75rem 1.5rem; }
  .app-brand { max-width: 230px; }
  .app-brand-text h1 { color: #fff; font-size: 1.05rem; }
  .app-brand-sub { color: rgba(255,255,255,.82); max-width: 210px; }
  .app-brand-mark { background: rgba(255,255,255,.14); }
  .header-actions { display: flex; flex-shrink: 0; }
  .btn-logout-icon { display: none; }
  .btn-logout-text { display: inline-flex; }
  .header-actions .btn-ghost { color: rgba(255,255,255,.88); }
  .header-actions .btn-ghost:hover { color: #fff; background: rgba(255,255,255,.12); border-radius: var(--radius-xs); }

  .app-nav--mobile { display: none; }
  .app-nav--desktop {
    display: flex; gap: .2rem;
    background: rgba(255,255,255,.12);
    padding: .25rem; border-radius: var(--radius-sm);
    flex: 1; justify-content: center; min-width: 0;
  }
  .app-nav--desktop .nav-item {
    flex-direction: row; gap: .38rem;
    padding: .45rem .75rem; font-size: .82rem;
    color: rgba(255,255,255,.82); border-radius: var(--radius-xs);
  }
  .app-nav--desktop .nav-item:hover { color: #fff; background: rgba(255,255,255,.1); }
  .app-nav--desktop .nav-item.active {
    color: var(--primary); background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
  }
  .app-nav--desktop .nav-item--admin {
    margin-left: .35rem;
    padding-left: .85rem;
    border-left: 1px solid rgba(255,255,255,.22);
    font-size: .76rem;
    opacity: .92;
  }
  .label-short { display: none; }

  .main-content { padding: 1.5rem 1.5rem 2.5rem; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .card { padding: 1.35rem 1.5rem; }
  .add-line-btn { width: auto; }
  .modal { align-items: center; }
  .modal-sheet { border-radius: var(--radius); }
  .toast { bottom: 1.5rem; }
}

@media (max-width: 767px) {
  .label-full { display: none; }
  .label-short { display: inline; }
  .app-brand-sub { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .btn { align-self: flex-start; }
}

@media print {
  .app-header, .app-nav, .page-header, .action-row, .no-print, .view-toolbar { display: none !important; }
  body { background: #fff; padding: 0; }
  .card { box-shadow: none; border: none; padding: 0; }
}
