:root {
    --navy: #07182d;
    --navy-2: #0d2342;
    --red: #c62835;
    --red-2: #a91f2c;
    --blue: #0d6efd;
    --green: #198754;
    --orange: #d97706;
    --gray-bg: #eef1f5;
    --line: #d7dde6;
    --text: #1f2937;
    --muted: #6b7280;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Arial, Helvetica, sans-serif; color: var(--text); }
body.app-body { background: var(--gray-bg); }
a { color: #0d6efd; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: var(--navy);
    color: white;
}
.brand-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 8px; background: #c62835; color: #fff; border: 2px solid rgba(255,255,255,.55); font-size: 12px; font-weight: 900; letter-spacing: .04em; }
.brand-title { font-size: 22px; font-weight: 800; letter-spacing: .04em; }
.brand-subtitle { font-size: 12px; color: #c7d4e5; }
.user-block { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-block small { color: #c7d4e5; }
.logout-link { color: white; padding: 7px 10px; border: 1px solid #49657f; border-radius: 6px; }

.main-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 24px;
    background: #102642;
    border-bottom: 3px solid var(--red);
}
.main-nav a {
    color: #eef5ff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
}
.main-nav a.active,
.main-nav a:hover { background: var(--red); text-decoration: none; }
.page-wrap { padding: 22px 24px 34px; }

.page-title { margin: 0 0 5px; font-size: 26px; color: var(--navy); }
.page-subtitle { margin: 0 0 18px; color: var(--muted); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card, .panel {
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(15, 23, 42, .05);
}
.card-pad, .panel { padding: 18px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat-card { padding: 18px; background: white; border: 1px solid var(--line); border-radius: 8px; }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; }
.stat-value { margin-top: 8px; color: var(--red); font-size: 36px; font-weight: 800; line-height: 1; }
.purpose-panel { padding: 20px; background: white; border-left: 5px solid var(--red); }
.purpose-panel h3 { margin: 0 0 8px; color: var(--navy); }
.purpose-panel p { margin: 0; color: #4b5563; line-height: 1.6; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { color: white; background: var(--blue); }
.btn-red { color: white; background: var(--red); }
.btn-red:hover { background: var(--red-2); }
.btn-green { color: white; background: var(--green); }
.btn-light { color: var(--text); background: white; border-color: var(--line); }
.btn-dark { color: white; background: var(--navy-2); }
.btn-sm { min-height: 31px; padding: 6px 9px; font-size: 12px; }

.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-group { margin-bottom: 14px; }
label { display: block; margin-bottom: 6px; color: #374151; font-weight: 700; font-size: 13px; }
input, select, textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: white;
    color: var(--text);
    font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(13, 110, 253, .14); border-color: #60a5fa; }
.alert { padding: 12px 14px; border-radius: 7px; margin-bottom: 14px; }
.alert-error { background: #fee2e2; border: 1px solid #fecaca; color: #7f1d1d; }
.alert-success { background: #dcfce7; border: 1px solid #bbf7d0; color: #14532d; }

.table-wrap { overflow-x: auto; background: white; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 13px; }
th { background: #f8fafc; color: #334155; text-transform: uppercase; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.thumb { width: 70px; height: 54px; object-fit: cover; border-radius: 6px; background: #e5e7eb; }
.badge { display: inline-block; padding: 5px 9px; border-radius: 999px; color: white; font-weight: 800; font-size: 11px; }
.badge-green { background: var(--green); }
.badge-red { background: var(--red); }
.badge-orange { background: var(--orange); }
.badge-gray { background: #6b7280; }

.map-page { height: calc(100vh - 128px); min-height: 560px; margin: -22px -24px -34px; position: relative; }
#map, #incidentMap { width: 100%; height: 100%; background: #dbeafe; }
.map-panel {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 900;
    width: 360px;
    max-width: calc(100% - 32px);
    max-height: calc(100% - 32px);
    overflow: auto;
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(0,0,0,.18);
    padding: 14px;
}
.map-panel h3 { margin: 0 0 8px; color: var(--navy); }
.incident-summary { padding: 10px; border-left: 4px solid var(--red); background: #fff5f5; margin-bottom: 12px; }
.hydrant-result { padding: 10px 0; border-top: 1px solid var(--line); }
.hydrant-result:first-child { border-top: 0; }
.distance { color: var(--red); font-weight: 800; }
.popup-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.popup-actions a { padding: 5px 8px; color: white !important; background: var(--blue); border-radius: 5px; font-size: 12px; }
.popup-actions a.waze { background: var(--green); }
.popup-actions a.google { background: #4285f4; }

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    color: white;
    background: radial-gradient(circle at 15% 15%, rgba(26,102,190,.28), transparent 34%),
                radial-gradient(circle at 88% 85%, rgba(198,38,50,.21), transparent 32%),
                #061426;
}
.login-container { width: 100%; max-width: 1080px; min-height: 620px; display: grid; grid-template-columns: 1.1fr .9fr; overflow: hidden; background: #0d2342; border: 1px solid #31577e; border-radius: 24px; box-shadow: 0 28px 80px rgba(0,0,0,.46); }
.login-brand { display: flex; align-items: center; padding: 52px; background: linear-gradient(145deg, rgba(4,17,33,.94), rgba(13,55,101,.91)); }
.login-mark { width: 150px; height: 150px; display: grid; place-items: center; border-radius: 24px; background: linear-gradient(145deg, #c62835, #7f1d1d); border: 4px solid rgba(255,255,255,.85); color: #fff; font-size: 38px; font-weight: 900; letter-spacing: .04em; margin-bottom: 26px; }
.login-brand h1 { margin: 0 0 12px; font-size: 40px; line-height: 1.1; }
.login-brand p { color: #bfd0e4; line-height: 1.6; }
.login-form { display: flex; align-items: center; padding: 48px; }
.login-form h2 { margin: 0 0 8px; font-size: 30px; }
.login-form .muted { color: #9fb3ca; }
.login-form label { color: #eaf2ff; }
.login-form input { color: white; background: #071a31; border-color: #315a83; }
.login-form input::placeholder { color: #7189a3; }

@media (max-width: 900px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .grid-4, .grid-2, .form-row { grid-template-columns: 1fr; }
    .login-container { grid-template-columns: 1fr; min-height: auto; }
    .login-brand { display: none; }
    .login-form { padding: 34px 24px; }
    .map-page { height: calc(100vh - 164px); }
}

@media (max-width: 560px) {
    .page-wrap { padding: 16px 12px 24px; }
    .main-nav { padding: 8px 12px; }
    .main-nav a { flex: 1 1 auto; text-align: center; }
    .stat-value { font-size: 30px; }
    .map-page { margin: -16px -12px -24px; }
    .map-panel { top: 10px; left: 10px; width: calc(100% - 20px); }
}
