/* =============================================================================
   Teik Fishery Employee Management System — shared styles (premium theme)
   Navy + teal maritime palette, Inter typography. Mobile-first responsive.
   ============================================================================= */

:root {
  /* palette */
  --bg: #f3f6f9;
  --surface: #ffffff;
  --border: #e2e9f0;
  --border-strong: #cfd9e3;
  --text: #14263a;
  --muted: #5d7287;
  --navy-900: #0a1c2c;
  --navy-800: #0e2940;
  --navy-700: #143a55;
  --primary: #0e7490;          /* deep teal */
  --primary-dark: #0b5c73;
  --primary-soft: #e6f3f7;
  --gold: #c9a14f;
  --danger: #c0392b;
  --danger-soft: #fdeae7;
  --ok: #1e7d3c;
  --ok-soft: #e6f4ea;
  --warn: #b07a06;
  --warn-soft: #fdf3dd;
  --warn-border: #e3b341;

  /* shape & depth */
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(10,28,44,.05), 0 8px 24px rgba(10,28,44,.06);
  --shadow-lift: 0 2px 4px rgba(10,28,44,.07), 0 14px 34px rgba(10,28,44,.12);
  --maxw: 1140px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }

h1,h2,h3,h4 { letter-spacing: -0.015em; }

/* ---- Top bar / navigation -------------------------------------------------- */
.topbar {
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-800) 60%, #103752 100%);
  color: #fff;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 14px rgba(10,28,44,.25);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 18px;
  display: flex; align-items: center; gap: 22px;
  min-height: 62px;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  color: #fff; text-decoration: none; flex: 0 0 auto;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(140deg, var(--primary) 0%, #14a3c0 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(14,116,144,.45);
}
.brand-mark svg { width: 20px; height: 20px; fill: #fff; }
.brand-mark.logo { background: #fff; padding: 3px; }
.brand-mark.logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; display: block; }
.brand strong { display: block; font-size: .98rem; font-weight: 700; line-height: 1.15; }
.brand small { display: block; font-size: .68rem; font-weight: 500; color: #9db4c6; letter-spacing: .02em; }

.topnav {
  display: flex; gap: 4px; flex: 1 1 auto;
  overflow-x: auto; scrollbar-width: none;
}
.topnav::-webkit-scrollbar { display: none; }
.nav-link {
  color: #b9cad8; font-size: .9rem; font-weight: 600;
  padding: 8px 13px; border-radius: 9px; white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-link.active { color: #fff; background: rgba(255,255,255,.13); box-shadow: inset 0 -2px 0 var(--gold); }

.topbar .user { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.user-chip {
  font-size: .78rem; color: #c4d3df; background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  padding: 6px 12px; border-radius: 999px; max-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.btn-ghost {
  background: transparent; color: #c4d3df;
  border: 1px solid rgba(255,255,255,.25);
  padding: 7px 14px; border-radius: 9px; font-size: .82rem; font-weight: 600;
  cursor: pointer; transition: all .15s ease; font-family: inherit;
}
.btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ---- Layout ----------------------------------------------------------------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 26px 18px 70px; }

.page-title { font-size: 1.45rem; font-weight: 800; margin: 4px 0 20px; color: var(--navy-900); }
.page-sub { color: var(--muted); font-size: .9rem; margin: -14px 0 20px; }

/* ---- Cards ------------------------------------------------------------------ */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

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

.nav-card {
  display: flex; gap: 14px; align-items: flex-start;
  transition: transform .14s ease, box-shadow .18s ease, border-color .18s ease;
}
.nav-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: var(--primary); }
.nav-card .icon {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 11px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.nav-card .icon svg { width: 22px; height: 22px; }
.nav-card h3 { margin: 2px 0 4px; color: var(--navy-900); font-size: 1.02rem; }
.nav-card p { margin: 0; color: var(--muted); font-size: .85rem; line-height: 1.45; }

/* ---- Stat cards --------------------------------------------------------------- */
.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 26px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; display: flex; align-items: center; gap: 14px;
}
.stat .stat-icon {
  width: 44px; height: 44px; border-radius: 12px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.stat .stat-icon svg { width: 22px; height: 22px; }
.stat-num { font-size: 1.55rem; font-weight: 800; color: var(--navy-900); line-height: 1.1; }
.stat-label { font-size: .78rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.stat.warn { border-color: var(--warn-border); background: linear-gradient(0deg, var(--warn-soft), #fff 70%); }

/* ---- Forms -------------------------------------------------------------------- */
.field { margin-bottom: 15px; }
.field label {
  display: block; font-size: .78rem; color: var(--muted);
  margin-bottom: 6px; font-weight: 700; letter-spacing: .02em;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: .95rem; font-family: inherit;
  background: #fff; color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3.5px rgba(14,116,144,.14);
}
/* iOS Safari: date inputs have an intrinsic width + centered text that
   overflows grid columns — normalise them. */
.field input, .field select, .field textarea { min-width: 0; max-width: 100%; }
.field input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-height: 44px;
  text-align: left;
}
input[type="date"]::-webkit-date-and-time-value { text-align: left; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border: none; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary) 0%, #11657f 100%);
  color: #fff; font-size: .93rem; font-family: inherit; font-weight: 700;
  cursor: pointer; transition: filter .15s ease, transform .1s ease, box-shadow .15s ease;
  box-shadow: 0 2px 8px rgba(14,116,144,.28);
}
button:hover, .btn:hover { filter: brightness(1.08); box-shadow: 0 4px 14px rgba(14,116,144,.35); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }

.btn-secondary {
  background: #fff; color: var(--navy-800);
  border: 1px solid var(--border-strong); box-shadow: none;
}
.btn-secondary:hover { background: #f3f7fa; filter: none; box-shadow: none; border-color: var(--primary); }
.btn-danger { background: linear-gradient(135deg, #c0392b, #a93226); box-shadow: 0 2px 8px rgba(192,57,43,.3); }

/* ---- Messages ------------------------------------------------------------------ */
.msg { padding: 12px 15px; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 500; margin-bottom: 16px; }
.msg-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f0c2bb; }
.msg-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #bfe0c8; }

/* ---- Tables --------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
th {
  background: #f4f8fb; color: var(--muted);
  font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  position: sticky; top: 0;
}
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #f7fafc; }
tr.expiring { background: var(--warn-soft); }
tr.expiring:hover { background: #fbedcc; }
tr.expiring td:first-child { box-shadow: inset 3px 0 0 var(--warn-border); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: .73rem; font-weight: 700;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-border); }
.badge-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #bfe0c8; }
.badge-muted { background: #eef1f4; color: var(--muted); border: 1px solid var(--border-strong); }
.msg-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-border); }

/* ---- Login ------------------------------------------------------------------------ */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(20,163,192,.25), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(201,161,79,.15), transparent 55%),
    linear-gradient(150deg, var(--navy-900) 0%, var(--navy-800) 55%, #11405e 100%);
}
.auth-card { width: 100%; max-width: 400px; padding: 34px 32px; border: none; }
.auth-logo {
  width: 52px; height: 52px; border-radius: 14px; margin-bottom: 18px;
  background: linear-gradient(140deg, var(--primary) 0%, #14a3c0 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(14,116,144,.4);
}
.auth-logo svg { width: 28px; height: 28px; fill: #fff; }
.auth-card h1 { font-size: 1.32rem; font-weight: 800; margin: 0 0 4px; color: var(--navy-900); }
.auth-card .sub { color: var(--muted); font-size: .88rem; margin: 0 0 24px; }
.auth-card button { width: 100%; padding: 13px; }

/* ---- Scan box (shared look for scan-or-manual) ------------------------------------- */
.scan-box {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  padding: 18px; background: #fbfdfe; margin-bottom: 20px;
  transition: border-color .15s ease;
}
.scan-box:hover { border-color: var(--primary); }
.scan-box.haspreview { border-style: solid; border-color: var(--primary); }
.scan-preview { max-width: 100%; max-height: 240px; border-radius: 10px; margin-top: 12px; display: block; box-shadow: var(--shadow); }

/* ---- Utilities ----------------------------------------------------------------------- */
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 auto; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }
.search-bar { margin-bottom: 18px; }
.search-bar input {
  max-width: 440px; width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: .93rem; font-family: inherit; background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search-bar input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3.5px rgba(14,116,144,.14); }

.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #e2ebf2; vertical-align: middle; display: inline-block; }
.avatar-sq { border-radius: 9px; }   /* square-ish frame for buildings & boats */

/* ---- Pager + mobile-only helpers ---------------------------------------------- */
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 18px 0 0; flex-wrap: wrap; }
.mobile-only { display: none !important; }
@media (max-width: 640px) {
  .mobile-only { display: inline-flex !important; }
}

/* ---- A–Z filter bar ---------------------------------------------------------- */
.alpha-bar { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 16px; }
.alpha-chip {
  padding: 5px 9px; border-radius: 7px;
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  font-size: .76rem; font-weight: 700; cursor: pointer;
  box-shadow: none; min-width: 30px;
}
.alpha-chip:hover { border-color: var(--primary); color: var(--primary); background: #fff; filter: none; box-shadow: none; }
.alpha-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

@media (max-width: 640px) {
  .brand small { display: none; }
  .user-chip { display: none; }
  .page-title { font-size: 1.25rem; }
  .container { padding: 18px 14px 60px; }
  .card { padding: 17px; }

  /* Topbar: brand + sign-out on row 1, nav links on their own row below */
  .topbar-inner { flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px; min-height: 0; }
  .brand { flex: 1 1 auto; }
  .topbar .user { flex: 0 0 auto; }
  .topnav { order: 3; flex: 1 1 100%; }

  /* Tighter stat cards (2-up) */
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
  .stat { padding: 12px 14px; gap: 10px; }
  .stat .stat-icon { width: 36px; height: 36px; border-radius: 10px; }
  .stat .stat-icon svg { width: 18px; height: 18px; }
  .stat-num { font-size: 1.25rem; }
  .stat-label { font-size: .68rem; }

  /* Lists: turn tables into stacked cards (uses td[data-label]) */
  .table-wrap { border: none; background: transparent; box-shadow: none; overflow: visible; }
  .table-wrap thead { display: none; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    padding: 8px 0;
  }
  .table-wrap td {
    border-bottom: none;
    padding: 6px 16px;
    white-space: normal;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    text-align: right;
    word-break: break-word;
  }
  .table-wrap td::before {
    content: attr(data-label);
    color: var(--muted); font-size: .7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em;
    text-align: left; flex: 0 0 auto;
  }
  .table-wrap td:not([data-label])::before { content: none; }
  .table-wrap td.cell-avatar { justify-content: flex-start; padding-bottom: 0; }
  .table-wrap td.cell-action { padding-top: 10px; }
  .table-wrap td.cell-action button { flex: 1; }
  tr.expiring td:first-child { box-shadow: none; }
  .table-wrap tr.expiring { border-left: 4px solid var(--warn-border); }
}
