/* SmoothByte IT PAT — design system. Mobile-first. */
:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --accent: #10B981;
  --danger: #DC2626;
  --warning: #D97706;
  --ink: #0F172A;
  --muted: #64748B;
  --line: #E2E8F0;
  --bg: #F1F5F9;
  --card: #FFFFFF;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --touch: 44px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
h1 { font-size: 1.45rem; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: .5rem 1rem;
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--ink); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; }
.brand-sub { color: var(--primary); font-weight: 600; }
.topnav { display: none; gap: .25rem; margin-left: auto; }
.topnav a {
  padding: .5rem .8rem; border-radius: 8px; color: var(--ink); font-weight: 500;
}
.topnav a:hover { background: var(--bg); text-decoration: none; }
.topnav a.active { background: var(--primary); color: #fff; }
.logout-form { margin-left: auto; }
@media (min-width: 860px) {
  .logout-form { margin-left: 0; }
  .topnav { display: flex; }
  body { padding-bottom: 2rem; }
  .bottomnav { display: none; }
}

/* Bottom nav (mobile) */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: .45rem 0 .4rem; font-size: .7rem; color: var(--muted); min-height: var(--touch);
}
.bottomnav a.active { color: var(--primary); font-weight: 600; }
.bottomnav a:hover { text-decoration: none; }
.bn-icon { font-size: 1.15rem; line-height: 1; }

.container { max-width: 1100px; margin: 0 auto; padding: 1rem; }

/* Cards */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem;
}
.card-title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--touch); padding: .5rem 1rem;
  border: 1px solid transparent; border-radius: 10px;
  font-size: 1rem; font-weight: 600; cursor: pointer;
  background: #fff; color: var(--ink); border-color: var(--line);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { min-height: 34px; padding: .25rem .7rem; font-size: .875rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Forms */
label { display: block; font-weight: 600; font-size: .875rem; margin: .75rem 0 .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=tel], input[type=search], select, textarea {
  width: 100%; min-height: var(--touch);
  padding: .5rem .75rem; font-size: 1rem; font-family: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary);
}
.field-error { color: var(--danger); font-size: .85rem; }
.form-grid { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.form-actions { margin-top: 1.25rem; display: flex; gap: .6rem; flex-wrap: wrap; }

/* Segmented pass/fail control */
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  flex: 1; margin: 0; padding: .55rem .25rem; text-align: center; cursor: pointer;
  font-weight: 600; font-size: .9rem; color: var(--muted); background: #fff; min-height: var(--touch);
  display: flex; align-items: center; justify-content: center;
}
.seg label + label { border-left: 1px solid var(--line); }
.seg input:checked + label.seg-pass { background: var(--accent); color: #fff; }
.seg input:checked + label.seg-fail { background: var(--danger); color: #fff; }
.seg input:checked + label.seg-na { background: var(--muted); color: #fff; }

/* Badges */
.badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 700; letter-spacing: .02em;
}
.badge-pass { background: #D1FAE5; color: #065F46; }
.badge-fail { background: #FEE2E2; color: #991B1B; }
.badge-na { background: var(--line); color: var(--muted); }
.badge-warn { background: #FEF3C7; color: #92400E; }
.badge-info { background: #DBEAFE; color: #1E40AF; }

/* Flash messages */
.flash {
  max-width: 1100px; margin: .75rem auto 0; padding: .65rem 1rem; border-radius: 10px; font-weight: 500;
}
.flash-success { background: #D1FAE5; color: #065F46; }
.flash-error { background: #FEE2E2; color: #991B1B; }
.flash-info { background: #DBEAFE; color: #1E40AF; }
@media (max-width: 1130px) { .flash { margin-left: 1rem; margin-right: 1rem; } }

/* Tables → cards on small screens */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); }
table.data th, table.data td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--line); }
table.data th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.data tr:hover td { background: #F8FAFC; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Stat tiles */
.stats { display: grid; gap: .75rem; grid-template-columns: repeat(2, 1fr); margin-bottom: 1rem; }
@media (min-width: 860px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: .85rem 1rem; }
.stat .stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.stat .stat-label { color: var(--muted); font-size: .8rem; font-weight: 600; }
.stat.stat-danger .stat-value { color: var(--danger); }
.stat.stat-accent .stat-value { color: var(--accent); }
.stat.stat-warn .stat-value { color: var(--warning); }

/* Login */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 1rem;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 2rem; width: 100%; max-width: 380px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .2); text-align: center;
}
.login-card h1 { margin: .5rem 0 0; }
.login-card form { text-align: left; margin-top: 1rem; }
.login-card .btn { margin-top: 1.25rem; }
.login-logo { width: 64px; height: 64px; border-radius: 14px; }

/* Utility */
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 860px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.right { text-align: right; }
.center { text-align: center; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: .55rem 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: none; }
.searchbar { display: flex; gap: .5rem; margin-bottom: .75rem; }
.searchbar input { flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
