/* Same look as the admin app (branding tokens can be swapped per client at the edge). */
:root {
  --color-primary: #0e5814;
  --color-primary-hover: #176f23;
  --color-bg: #f7f8f7;
  --color-panel: #ffffff;
  --color-border: #e0e0e0;
  --color-text: #1a1a1a;
  --color-text-muted: #6b6b6b;

  --color-expired: #ffcccc;
  --color-expiring30: #ffe5cc;
  --color-expiring60: #ffffcc;
  --color-expiring90: #cce6ff;
  --color-active: #e7f4e7;

  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

/* The hidden attribute always wins over class rules that set display. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 16px; /* 16px inputs stop iPhones zooming in on focus */
}

/* ---------- Top bar + slide-out menu ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-primary);
  color: #fff;
  padding: 14px 18px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15em; }
.brand-mark { color: #9ee6a8; }

.menu-toggle {
  background: none; border: none; cursor: pointer;
  width: 40px; height: 40px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.menu-toggle span { display: block; width: 22px; height: 2px; background: #fff; border-radius: 2px; }

.side-menu {
  position: fixed; top: 0; right: -82%; width: 82%; max-width: 300px; height: 100%;
  background: var(--color-panel);
  box-shadow: -2px 0 12px rgba(0,0,0,0.15);
  z-index: 40;
  transition: right 0.25s ease;
  display: flex; flex-direction: column;
}
.side-menu.open { right: 0; }

.side-menu-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 700; color: var(--color-primary);
}

.menu-close { background: none; border: none; font-size: 1.8em; cursor: pointer; color: var(--color-text-muted); line-height: 1; }

.side-menu-list { list-style: none; margin: 0; padding: 8px 0; }

.side-menu-link {
  display: block; padding: 16px 20px;
  color: var(--color-text); text-decoration: none;
  border-left: 3px solid transparent;
}
.side-menu-link.active { border-left-color: var(--color-primary); color: var(--color-primary); font-weight: 600; background: #eef6ee; }

.side-menu-scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 30; display: none; }
.side-menu-scrim.open { display: block; }

/* ---------- Layout ---------- */

.app-main { max-width: 640px; margin: 0 auto; padding: 18px 16px 60px; }

.view-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.view-header h1 { margin: 0; font-size: 1.4em; color: var(--color-primary); }

.panel { background: var(--color-panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.panel + .panel { margin-top: 14px; }
.panel p:first-child { margin-top: 0; }
.panel-title { font-size: 1.05em; margin: 0 0 6px; }

.banner {
  background: #eef6ee; color: var(--color-primary);
  border-radius: 6px; padding: 10px 14px; margin: 0 0 12px; font-size: 0.92em;
}
.banner-warn { background: #fff3e0; color: #b06a00; }
.banner a { color: inherit; font-weight: 600; }

.empty-state { text-align: center; color: var(--color-text-muted); padding: 40px 10px; }

/* ---------- Buttons ---------- */

.btn { border: none; border-radius: 6px; padding: 12px 18px; font-size: 1em; font-weight: 600; cursor: pointer; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-block { width: 100%; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: #eee; color: var(--color-text); }
.btn-danger-outline { background: none; color: #c0392b; border: 1px solid #c0392b; }
.btn-link { background: none; border: none; color: var(--color-primary); cursor: pointer; font-weight: 600; padding: 6px 8px; font-size: 0.95em; }

/* ---------- Cert cards ---------- */

.cert-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.cert-card {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
  text-align: left;
  background: var(--color-panel);
  border: none;
  border-left: 5px solid #7cc284;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.cert-card-title { font-weight: 700; grid-column: 1; }
.cert-card-sub { color: var(--color-text-muted); font-size: 0.88em; grid-column: 1; }
.cert-card .status-chip { grid-column: 2; grid-row: 1 / span 2; }

.cert-card.row-expired    { border-left-color: #c0392b; background: #fff6f6; }
.cert-card.row-badDate    { border-left-color: #8e44ad; }
.cert-card.row-expiring30 { border-left-color: #d68a1f; }
.cert-card.row-expiring60 { border-left-color: #c7b515; }
.cert-card.row-expiring90 { border-left-color: #3178c6; }
.cert-card.row-renewed    { border-left-color: #bbb; opacity: 0.7; }

.status-chip {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 0.78em; font-weight: 600; background: var(--color-active); white-space: nowrap;
}
.status-chip.status-expired    { background: #f5a3a3; }
.status-chip.status-badDate    { background: #d9b3f0; }
.status-chip.status-expiring30 { background: #f5c98a; }
.status-chip.status-expiring60 { background: #eae08a; }
.status-chip.status-expiring90 { background: #a3c9f5; }
.status-chip.status-renewed    { background: #e4e4e4; color: var(--color-text-muted); }

/* ---------- Forms ---------- */

.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; min-width: 0; }
.form-group-narrow { flex: 0 0 70px !important; }
.form-group-inline { display: flex; align-items: center; }

.form-group label { display: block; font-size: 0.88em; font-weight: 600; margin-bottom: 6px; }
.form-group-inline label { display: flex; align-items: center; gap: 8px; font-size: 1em; font-weight: 400; }
.req { color: #c0392b; }

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group input[type="date"],
.form-group input[type="file"],
.form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
}
.form-group input:disabled { background: #f2f2f2; color: var(--color-text-muted); }
.form-group textarea { resize: vertical; }

.field-hint { font-size: 0.82em; color: var(--color-text-muted); margin: 6px 0 0; }
.field-hint-error { color: #c0392b; }

.attachment-list { list-style: none; margin: 8px 0 0; padding: 0; }
.attachment-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--color-border); font-size: 0.9em; }
.attachment-item:last-child { border-bottom: none; }
.attachment-thumb {
  flex: 0 0 48px; width: 48px; height: 48px; object-fit: cover; border-radius: 4px;
  background: var(--color-bg); display: flex; align-items: center; justify-content: center;
  font-size: 0.75em; font-weight: 700; color: #c0392b;
}
.attachment-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-primary); }

/* ---------- Modal (full screen on phones) ---------- */

.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; }
.modal { background: var(--color-panel); width: 100%; max-width: 560px; min-height: 100%; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; background: var(--color-panel); z-index: 1;
}
.modal-header h2 { margin: 0; font-size: 1.15em; color: var(--color-primary); }
.modal-close { background: none; border: none; font-size: 1.8em; cursor: pointer; color: var(--color-text-muted); line-height: 1; }
.modal-body { padding: 18px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.modal-actions .spacer { flex: 1; }

@media (min-width: 600px) {
  .modal-scrim { padding: 40px 16px; }
  .modal { min-height: 0; border-radius: var(--radius); }
}
