:root {
  --primary: #1a73e8;
  --danger: #d93025;
  --success: #1a7f37;
  --bg: #f5f5f7;
  --text: #1a1a1a;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win over a class's own display value
   (e.g. .stack/.modal-backdrop set display:flex, which otherwise ties in
   specificity with the browser's [hidden]{display:none} and can lose). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-size: 18px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  min-height: 100vh;
}
.home h1 { margin-bottom: 2rem; }
.menu {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 420px;
}
.menu-btn {
  display: block;
  text-align: center;
  padding: 1.25rem;
  font-size: 1.25rem;
  border-radius: 12px;
  border: none;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-family: inherit;
}
.menu-btn:disabled { background: #c8c8cc; color: #6e6e73; }

.app-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: #fff;
  border-bottom: 1px solid #ddd;
  position: sticky;
  top: 0;
}
.app-header h1 { font-size: 1.25rem; margin: 0; }
.back-link { text-decoration: none; color: var(--primary); font-size: 1rem; }

.stack { display: flex; flex-direction: column; gap: 1.25rem; }
.field { display: flex; flex-direction: column; gap: .4rem; font-size: 1rem; }
.field input, .field select {
  padding: .9rem;
  font-size: 1.1rem;
  border-radius: 10px;
  border: 1px solid #ccc;
  background: #fff;
  font-family: inherit;
}

.autocomplete-results { list-style: none; margin: 0; padding: 0; border-radius: 10px; overflow: hidden; }
.autocomplete-results li { padding: .8rem; background: #fff; border-bottom: 1px solid #eee; }
.autocomplete-results li:active { background: #e8f0fe; }
.selected-chip { font-size: .9rem; color: var(--success); }

.primary-btn {
  padding: 1.1rem;
  font-size: 1.2rem;
  border: none;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  width: 100%;
  font-family: inherit;
}
.primary-btn:disabled { opacity: .6; }
.secondary-btn {
  display: block;
  text-align: center;
  padding: 1.1rem;
  font-size: 1.2rem;
  border-radius: 12px;
  background: #e5e5ea;
  color: #1a1a1a;
  text-decoration: none;
}
.error-banner { background: #fdecea; color: var(--danger); padding: .8rem; border-radius: 10px; }

.scan-banner { padding: .7rem; border-radius: 10px; font-size: .95rem; }
.scan-banner.level-high { background: #e6f4ea; color: var(--success); }
.scan-banner.level-low { background: #fff4e5; color: #8a5a00; }
.scan-banner.level-warn { background: #fdecea; color: var(--danger); }

.success-screen { text-align: center; padding: 2rem 1rem; }
.success-icon { font-size: 3rem; color: var(--success); }
.success-actions { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.5rem; }

.details-card { background: #fff; border-radius: 12px; padding: .5rem 1rem; }
.details-card p { display: flex; justify-content: space-between; align-items: baseline; padding: .6rem 0; border-bottom: 1px solid #eee; margin: 0; gap: 1rem; }
.details-card p:last-child { border-bottom: none; }
.details-card p span { color: #6e6e73; font-size: .95rem; }
.details-card p strong { text-align: right; }

textarea { padding: .9rem; font-size: 1.1rem; border-radius: 10px; border: 1px solid #ccc; background: #fff; font-family: inherit; resize: vertical; }

/* Idle Manage screen: blank until a scan comes in */
.idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  min-height: 70vh;
  padding: 1rem;
}
.scan-status {
  min-height: 1.6rem;
  font-size: 1.1rem;
  letter-spacing: .04em;
  color: #8a8a8e;
}

/* Everything else spawns as a modal over the blank idle screen */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 10;
}
.modal-card {
  position: relative;
  background: var(--bg);
  border-radius: 16px;
  padding: 1.75rem 1.25rem 1.25rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-close {
  position: absolute;
  top: .4rem;
  right: .6rem;
  background: none;
  border: none;
  font-size: 1.75rem;
  line-height: 1;
  color: #8a8a8e;
  cursor: pointer;
  padding: .25rem .5rem;
}
