* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --brand: #1857e0;
  --brand-dark: #123f9e;
  --brand-light: #eaf1ff;
  --accent: #d7f200;
  --bg: #f7f7fa;
  --card: #ffffff;
  --border: #e8e8f0;
  --text: #1a1d27;
  --muted: #6b7280;
  --muted-light: #9ca3af;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif; background: var(--bg); color: var(--text); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: inherit; }

/* Login */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--brand-light), #fff); }
.login-box { background: var(--card); border-radius: 16px; box-shadow: 0 8px 32px rgba(181,69,27,.12); padding: 40px; width: 360px; }
.login-box h1 { font-size: 24px; font-weight: 800; margin-bottom: 4px; text-align: center; }
.login-box .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-box .field { margin-bottom: 14px; }
.login-box label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.login-box input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; }
.login-box input:focus { outline: none; border-color: var(--brand); }
.login-box .btn { width: 100%; margin-top: 8px; }

/* App shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #fff; color: var(--text); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar .brand { padding: 20px; font-size: 18px; font-weight: 800; border-bottom: 1px solid var(--border); color: var(--text); }
.sidebar .brand span { color: var(--brand); }
.sidebar nav { flex: 1; padding: 12px 0; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 11px 20px; font-size: 14px; color: var(--muted); text-decoration: none; cursor: pointer; }
.sidebar nav a:hover { background: var(--brand-light); color: var(--brand); }
.sidebar nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.sidebar .user-box { padding: 16px 20px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text); }
.sidebar .user-box button { background: none; border: none; color: var(--muted-light); font-size: 12px; margin-top: 6px; padding: 0; }

.content { flex: 1; padding: 28px 32px; overflow-y: auto; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-header h1 { font-size: 22px; font-weight: 800; }

/* Buttons */
.btn { padding: 10px 18px; min-height: 40px; border-radius: 8px; border: none; font-size: 13.5px; font-weight: 600; touch-action: manipulation; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-outline { background: #fff; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { background: #f9fafb; }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-sm { padding: 7px 12px; min-height: 34px; font-size: 12.5px; }

/* Cards / stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; }
.stat-card .val { font-size: 26px; font-weight: 800; }
.stat-card .lbl { font-size: 11.5px; color: var(--muted-light); text-transform: uppercase; letter-spacing: .4px; margin-top: 4px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; }
.card h3 { font-size: 14px; margin-bottom: 12px; }

/* Table */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
table.data-table { width: 100%; min-width: 560px; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
table.data-table th { background: #f8f8fc; text-align: left; padding: 12px 14px; font-size: 11px; font-weight: 700; color: var(--muted-light); text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--border); }
table.data-table td { padding: 13px 14px; border-bottom: 1px solid #f0f0f5; font-size: 13.5px; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: #fafafd; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-gray { background: #f0f0f5; color: #6b7280; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-orange { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 16px; }
.modal-header button { background: none; border: none; font-size: 20px; color: var(--muted); }
.modal-body { padding: 20px 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: #374151; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; min-height: 40px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 14px; }
.field textarea { min-height: unset; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); }
.field input[type="checkbox"] { width: 16px; height: 16px; padding: 0; border-radius: 3px; flex-shrink: 0; accent-color: var(--brand); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--muted-light); font-size: 14px; }
.toast { position: fixed; bottom: 24px; right: 24px; background: #1a1d27; color: #fff; padding: 12px 20px; border-radius: 8px; font-size: 13.5px; z-index: 200; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.toast.error { background: #991b1b; }
.toast.success { background: #15803d; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-top: 8px; }
.photo-grid img { width: 100%; height: 70px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

@media (max-width: 860px) {
  .content { padding: 20px 16px; }
  .field-row, .detail-grid { grid-template-columns: 1fr; }
}

/* Phone only — the sidebar has room to stay fully labeled on tablets */
@media (max-width: 640px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .sidebar .brand { padding: 14px 16px; border-bottom: none; }
  .sidebar nav { display: flex; flex: none; padding: 0; overflow-x: auto; }
  .sidebar nav a { padding: 10px 14px; white-space: nowrap; }
  .sidebar nav a span.label { display: none; }
  .sidebar nav a span.icon { font-size: 18px; }
  .sidebar .user-box { margin-left: auto; border-top: none; padding: 10px 16px; }
  .sidebar .user-box span { display: none; }
}
