:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-muted: #eef2f7;
  --text: #0f172a;
  --muted: #64748b;
  --line: #dbe2ea;
  --line-soft: #e8edf3;
  --primary: #0f172a;
  --success: #16a34a;
  --success-soft: #ecfdf5;
  --success-line: #bbf7d0;
  --danger-soft: #fef2f2;
  --danger-line: #fecaca;
  --danger-text: #991b1b;
  --shadow: 0 8px 25px rgba(15, 23, 42, 0.06);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Manrope", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.patrol-page-body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.page-shell {
  min-height: 100vh;
}

.page-shell-login {
  display: flex;
  flex-direction: column;
}

.brand-header,
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px clamp(18px, 4vw, 40px);
  background: rgba(248, 250, 252, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}

.brand-header-login {
  justify-content: center;
  border-bottom: none;
  background: transparent;
  padding-top: 42px;
  padding-bottom: 8px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-lockup-centered {
  margin: 0 auto;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #fff;
  background: var(--primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  font-weight: 800;
  font-size: 24px;
}

.brand-name {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
}

.login-layout {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 12px 16px 40px;
}

.login-card {
  width: min(100%, 620px);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow);
  border-radius: var(--radius-xl);
  padding: clamp(28px, 4vw, 38px);
}

.login-card-header {
  text-align: center;
  margin-bottom: 26px;
}

.login-card-header h1,
.success-screen h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.form-stack,
.field-group {
  display: grid;
  gap: 10px;
}

.form-stack {
  gap: 18px;
}

.field-group label {
  font-weight: 700;
  font-size: 0.98rem;
}

.field-group input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-md);
  min-height: 58px;
  padding: 0 18px;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06);
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 76px;
}

.ghost-toggle {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.primary-button,
.logout-button,
.back-link {
  border: none;
  border-radius: var(--radius-md);
  min-height: 54px;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease;
}

.primary-button {
  color: #fff;
  background: var(--primary);
}

.logout-button {
  min-height: 44px;
  background: transparent;
  color: var(--text);
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  background: var(--surface-muted);
  color: var(--text);
}

.primary-button:hover,
.logout-button:hover,
.back-link:hover {
  transform: translateY(-1px);
}

.message {
  display: none;
  padding: 16px;
  border-radius: 15px;
  font-size: 14px;
  line-height: 1.5;
}

.message.show {
  display: block;
}

.message.error {
  background: var(--danger-soft);
  border: 1px solid var(--danger-line);
  color: var(--danger-text);
}

.message.success {
  background: var(--success-soft);
  border: 1px solid var(--success-line);
  color: #166534;
}

.content-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.content-shell-patrol {
  width: min(560px, calc(100% - 24px));
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: #334155;
  font-weight: 800;
  font-size: 12px;
  text-transform: lowercase;
}

.signed-in-line {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 15px;
}

.dashboard-sections {
  display: grid;
  gap: 28px;
}

.dashboard-group h3 {
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary);
  color: var(--text);
  font-size: 1.7rem;
  line-height: 1.1;
}

.dashboard-cards {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-card,
.patrol-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line-soft);
}

.dashboard-card {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 82px;
}

.dashboard-card-main {
  display: block;
}

.dashboard-card-title {
  font-size: 1.22rem;
  font-weight: 800;
}

.logout-button {
  font-size: 13px;
  min-height: 38px;
  padding: 0 8px;
}

.patrol-app {
  width: 100%;
  max-width: 100%;
  margin: 0;
  min-height: 100vh;
  background: var(--surface-soft);
}

.patrol-header {
  background: var(--primary);
  color: white;
  padding: 18px 22px 34px;
  border-radius: 0 0 34px 34px;
}

.patrol-header-small {
  font-size: 12px;
  letter-spacing: 1.5px;
  opacity: 0.7;
  font-weight: 700;
}

.patrol-header h1 {
  margin: 16px 0 6px;
  font-size: 31px;
  line-height: 1.06;
  letter-spacing: -0.8px;
}

.patrol-header p {
  margin: 0;
  opacity: 0.7;
  font-size: 15px;
}

.patrol-content {
  padding: 26px 20px 18px;
}

.patrol-message {
  margin-bottom: 15px;
}

.patrol-content > .patrol-card + .patrol-card {
  margin-top: 26px;
}

.patrol-step-title {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 16px;
  font-weight: 750;
  margin-bottom: 14px;
}

.patrol-step-number {
  width: 30px;
  height: 30px;
  background: var(--primary);
  color: white;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.patrol-card label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #334e68;
}

.patrol-input {
  width: 100%;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0 20px;
  font-size: 18px;
  outline: none;
  background: #fff;
  color: var(--text);
  transition: 0.2s;
}

.patrol-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06);
}

.patrol-input[readonly] {
  background: var(--surface-soft);
  color: #334155;
}

.patrol-primary-btn,
.patrol-secondary-btn,
.patrol-photo-btn {
  width: 100%;
  min-height: 68px;
  border: 0;
  border-radius: 18px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  transition: 0.15s;
}

.patrol-primary-btn,
.patrol-photo-btn {
  background: var(--primary);
  color: white;
}

.patrol-secondary-btn {
  margin-top: 15px;
  background: var(--surface-muted);
  color: var(--text);
}

.patrol-photo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  white-space: nowrap;
  line-height: 1;
}

.patrol-primary-btn:active,
.patrol-photo-btn:active {
  transform: scale(0.985);
}

.scanner-reader {
  width: 100%;
  overflow: hidden;
  border-radius: 16px;
  margin-top: 15px;
  display: none;
}

.scanner-reader video {
  border-radius: 16px;
}

.checkpoint-result {
  display: none;
  background: var(--success-soft);
  border: 1px solid var(--success-line);
  border-radius: 15px;
  padding: 16px;
}

.checkmark {
  width: 38px;
  height: 38px;
  background: var(--success);
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  margin-bottom: 10px;
}

.checkpoint-result-label {
  font-size: 12px;
  color: #15803d;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

.checkpoint-name {
  font-size: 22px;
  font-weight: 800;
  margin-top: 4px;
  color: #14532d;
}

.checkpoint-id {
  font-size: 13px;
  color: var(--success);
  margin-top: 4px;
}

.hidden-input {
  display: none;
}

.photo-attached {
  display: none;
  background: var(--success-soft);
  border: 1px solid var(--success-line);
  border-radius: 14px;
  padding: 14px 15px;
  font-weight: 700;
  color: #166534;
  align-items: center;
  justify-content: space-between;
}

.replace-photo {
  font-size: 12px;
  border: none;
  background: transparent;
  color: #166534;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.patrol-info {
  text-align: center;
  font-size: 12px;
  color: #94a3b8;
  margin: 20px 10px 18px;
}

.submit-panel {
  position: sticky;
  bottom: 0;
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(10px);
  padding: 12px 0 18px;
}

.submit-btn {
  width: 100%;
  min-height: 72px;
  border: none;
  border-radius: 20px;
  background: var(--success);
  color: white;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.submit-btn:disabled,
.patrol-primary-btn:disabled,
.patrol-photo-btn:disabled,
.patrol-secondary-btn:disabled {
  background: #cbd5e1 !important;
  color: #64748b !important;
  cursor: not-allowed;
  transform: none !important;
}

.success-screen {
  display: none;
  text-align: center;
  padding: 45px 20px;
}

.success-screen p {
  color: var(--muted);
  margin-bottom: 28px;
}

.success-icon {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: var(--success);
  color: white;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

@media (max-width: 780px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-lockup-centered {
    margin: 0;
  }

  .user-bar {
    width: 100%;
    justify-content: space-between;
  }

  .dashboard-cards {
    grid-template-columns: 1fr;
  }

  .content-shell {
    width: min(100%, calc(100% - 24px));
  }
}

@media (max-width: 560px) {
  .brand-header,
  .app-header {
    padding: 18px 14px;
  }

  .brand-name {
    font-size: 1.3rem;
  }

  .login-card {
    padding: 22px 18px;
  }

  .login-card-header h1 {
    font-size: 2.15rem;
  }

  .dashboard-card,
  .patrol-card {
    padding: 22px;
  }

  .patrol-content {
    padding: 26px 18px 16px;
  }
}
