@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');
:root {
  color-scheme: light;
  --navy: #17344c;
  --blue: #398ebc;
  --blue-dark: #2578a6;
  --cyan: #e8f4fa;
  --bg: #f4f7f9;
  --surface: #ffffff;
  --text: #263c4d;
  --muted: #6b7e8c;
  --line: #e0e7ec;
  --green: #208764;
  --green-bg: #eaf5ef;
  --red: #a92d3b;
  --red-bg: #fff3f2;
  --shadow: 0 5px 18px rgba(31, 58, 77, .055);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --navy: #eef5f9;
  --blue: #70b9e3;
  --blue-dark: #8bc9ec;
  --cyan: #203848;
  --bg: #111c26;
  --surface: #1a2935;
  --text: #e6edf2;
  --muted: #a4b3bd;
  --line: #33434f;
  --green: #72c8a3;
  --green-bg: #203b34;
  --red: #f08b92;
  --red-bg: #442a30;
  --shadow: 0 5px 18px rgba(0,0,0,.16);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Cairo", Tahoma, Arial, sans-serif; line-height: 1.65; transition: background .2s,color .2s; }
button,input,select,textarea { font: inherit; }
button,a { transition: background .16s,border-color .16s,color .16s,transform .16s; }
a { color: inherit; text-decoration: none; }
.topbar { min-height: 70px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px max(calc((100% - 1120px)/2),24px); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--navy); font-weight: 800; letter-spacing: .2px; line-height: 1.15; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 24px; }
.brand small { display: block; font-size: 9px; color: var(--muted); letter-spacing: 1.3px; margin-top: 4px; }
.header-tools { display: flex; align-items: center; gap: 9px; }
.prototype-tag { font-size: 11px; color: var(--green); background: var(--green-bg); border: 1px solid var(--line); padding: 5px 11px; border-radius: 30px; font-weight: 700; }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 11px; font-weight: 700; cursor: pointer; }
.theme-toggle:hover { border-color: var(--blue); color: var(--blue); }
.theme-icon { font-size: 16px; line-height: 1; }
.shell { max-width: 1120px; margin: 28px auto; padding: 0 24px; }
.hero { min-height: 220px; padding: 36px 40px; background: linear-gradient(115deg,#e6f3f9,#f9fcfd); border: 1px solid #d8e9f1; border-radius: 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; overflow: hidden; }
.hero h1 { max-width: 680px; color: #173a55; font-size: clamp(28px,3.5vw,40px); line-height: 1.3; margin: 5px 0 10px; }
.hero-copy { color: #5e7482; margin: 0; max-width: 620px; }
.hero-symbol { width: 100px; height: 100px; flex: 0 0 auto; border-radius: 28px; background: rgba(255,255,255,.8); color: var(--blue); display: grid; place-items: center; font-size: 58px; }
.eyebrow { font-size: 11px; letter-spacing: .7px; font-weight: 800; color: var(--blue-dark); margin: 0; }
.section-heading,.page-title { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 29px 0 17px; }
.section-heading h2,.page-title h1 { margin: 2px 0; font-size: 25px; color: var(--navy); }
.button { border: 1px solid transparent; border-radius: 10px; min-height: 41px; padding: 9px 16px; font-weight: 700; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.button:hover { transform: translateY(-1px); }
.button:focus-visible,a:focus-visible,.theme-toggle:focus-visible { outline: 3px solid #8bc6e6; outline-offset: 3px; }
.primary { background: var(--blue); color: #fff; }
.primary:hover { background: var(--blue-dark); }
.secondary { background: var(--cyan); color: var(--navy); border-color: var(--line); }
.ghost { background: var(--surface); color: var(--blue-dark); border-color: var(--line); }
.danger-outline { background: var(--surface); color: var(--red); border-color: #e7c8cc; }
.stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 13px; margin: 18px 0; }
.stat-card,.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.stat-card { padding: 17px 20px; display: grid; grid-template-columns: 42px 1fr; column-gap: 12px; align-items: center; }
.stat-icon { grid-row: span 2; background: var(--cyan); color: var(--blue-dark); width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-card strong { font-size: 27px; color: var(--navy); line-height: 1.2; }
.panel { padding: 23px; }
.panel h3,.panel-head h3 { margin: 0; color: var(--navy); font-size: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.panel-head p,.panel>p { margin: 4px 0; color: var(--muted); font-size: 12px; }
.search { width: 220px; max-width: 100%; padding: 10px 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); outline: none; }
.search:focus,input:focus,select:focus,textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(57,142,188,.13); outline: none; }
.profiles-list { display: grid; gap: 10px; margin-top: 18px; }
.profile-row { display: flex; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 12px; padding: 13px; background: var(--surface); }
.profile-avatar { width: 43px; height: 43px; border-radius: 12px; background: var(--cyan); color: var(--blue-dark); display: grid; place-items: center; font-weight: 800; font-size: 20px; flex-shrink: 0; }
.profile-info { flex: 1; min-width: 0; }
.profile-info strong { display: block; color: var(--navy); }
.profile-info span { font-size: 12px; color: var(--muted); }
.profile-row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.status-pill { font-size: 11px; color: var(--green); background: var(--green-bg); border-radius: 30px; padding: 4px 10px; font-weight: 700; }
.status-pill.off { color: var(--red); background: var(--red-bg); }
.empty-state { text-align: center; padding: 34px 20px; display: none; }
.empty-state.show { display: block; }
.empty-icon { width: 54px; height: 54px; background: var(--cyan); border-radius: 15px; display: grid; place-items: center; margin: 0 auto 12px; color: var(--blue); font-size: 26px; }
.empty-state h3,.empty-state h1 { color: var(--navy); margin: 5px; }
.empty-state p { color: var(--muted); font-size: 13px; max-width: 460px; margin: 5px auto 18px; }
.hidden { display: none!important; }
.form-panel { max-width: 900px; margin: auto; }
.form-section { padding: 5px 0 22px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.form-section h3 { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.form-grid input,.form-grid select,.form-grid textarea,.login-form input { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 10px 12px; color: var(--text); font-size: 13px; resize: vertical; }
.form-grid input[type=checkbox] { width: auto; min-height: 0; }
.full { grid-column: 1/-1; }
.field-note { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.sensitive-section { background: #fffaf2; border: 1px solid #eee2c8; border-radius: 12px; padding: 18px; }
.check-label { flex-direction: row!important; align-items: center; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.form-message { font-size: 13px; color: var(--green); }
.login-panel { max-width: 520px; margin: 18px auto; }
.login-panel h2 { margin: 0; color: var(--navy); font-size: 20px; }
.login-form { display: grid; gap: 13px; }
.login-form label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.login-form button { justify-self: start; }
.detail-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0; }
.qr-area { display: grid; grid-template-columns: 250px 1fr; gap: 20px; align-items: center; border-top: 1px solid var(--line); padding-top: 22px; margin-top: 12px; }
.qr-box { min-height: 250px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 12px; }
.qr-box img,.qr-box canvas { max-width: 100%; height: auto; }
.qr-box:empty:after { content: "QR"; font-size: 35px; color: var(--line); }
.qr-area h4 { margin: 0; color: var(--navy); }
.url-text { font-size: 10px; overflow-wrap: anywhere; color: var(--muted); }
.summary-list { display: grid; gap: 0; margin-top: 12px; }
.summary-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.summary-item span { display: block; font-size: 11px; color: var(--muted); }
.summary-item strong { font-size: 13px; overflow-wrap: anywhere; }
.notice { border: 1px solid #eadfca; background: #fffaf2; color: #725d2d; border-radius: 11px; padding: 12px 15px; margin: 18px 0; font-size: 13px; }
.public-shell { max-width: 780px; margin: 26px auto; padding: 0 20px; }
.public-card { padding: 24px; }
.public-top { display: flex; gap: 15px; align-items: center; margin-bottom: 17px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.avatar { width: 62px; height: 62px; border-radius: 16px; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 32px; }
.public-top h1 { margin: 2px 0; color: var(--navy); font-size: 26px; }
.muted { color: var(--muted); margin: 0; font-size: 13px; }
.emergency-banner { display: flex; align-items: center; justify-content: space-between; gap: 15px; background: var(--red-bg); border: 1px solid #efd5d6; border-radius: 13px; padding: 15px; margin: 0 0 18px; }
.emergency-copy { display: flex; align-items: center; gap: 12px; min-width: 0; }
.emergency-mark { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; color: var(--red); background: rgba(169,45,59,.09); }
.emergency-mark svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.emergency-banner strong { color: var(--red); font-size: 14px; }
.emergency-banner p { margin: 3px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.emergency-button { min-width: 190px; min-height: 50px; flex: 0 0 auto; background: var(--red); color: #fff; border-radius: 10px; font-size: 15px; }
.emergency-button:hover { background: #8e1f2d; }
.medical-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.medical-item { display: flex; gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; min-width: 0; background: var(--surface); }
.medical-icon { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 11px; background: var(--cyan); color: var(--blue-dark); display: grid; place-items: center; }
.medical-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.allergy-icon { color: #a56d20; background: #fff6e6; }
.medical-item h3 { font-size: 13px; margin: 0; color: var(--navy); }
.medical-item p { font-size: 13px; margin: 5px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.full-item { grid-column: 1/-1; }
.privacy-note { font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; margin-top: 18px; }
footer { text-align: center; color: var(--muted); font-size: 11px; padding: 25px 0 12px; }
footer span { padding: 0 7px; }
.public-body { background: var(--bg); }
:root[data-theme="dark"] body { background: var(--bg); }
:root[data-theme="dark"] .topbar,:root[data-theme="dark"] .panel,:root[data-theme="dark"] .stat-card,:root[data-theme="dark"] .profile-row,:root[data-theme="dark"] .medical-item,:root[data-theme="dark"] .qr-box,:root[data-theme="dark"] .theme-toggle { background: var(--surface); }
:root[data-theme="dark"] .hero { background: linear-gradient(115deg,#1b3344,#203c4d); border-color: var(--line); }
:root[data-theme="dark"] .hero h1,:root[data-theme="dark"] .hero-copy { color: var(--text); }
:root[data-theme="dark"] .hero-symbol { background: #263e4f; }
:root[data-theme="dark"] .notice,:root[data-theme="dark"] .sensitive-section { background: #302d26; border-color: #514638; color: #e8d9b5; }
:root[data-theme="dark"] .emergency-banner { background: #3a252b; border-color: #5b353c; }
:root[data-theme="dark"] .allergy-icon { background: #403522; color: #edc37b; }
:root[data-theme="dark"] .emergency-button { color: #fff; background: #bd3b4b; }
@media (max-width: 720px) {
  .topbar { min-height: 64px; padding: 8px 14px; }
  .shell { padding: 0 14px; margin: 18px auto; }
  .hero { min-height: 190px; padding: 24px 21px; }
  .hero-symbol { width: 68px; height: 68px; border-radius: 18px; font-size: 38px; }
  .hero h1 { font-size: 27px; }
  .stats { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }
  .stat-card { min-height: 104px; grid-template-columns: 1fr; gap: 5px; padding: 10px 8px; }
  .stat-icon { grid-row: auto; width: 31px; height: 31px; }
  .stat-card strong { font-size: 22px; }
  .stat-label { font-size: 10px; }
  .section-heading { align-items: flex-start; }
  .section-heading .button { padding: 8px 10px; font-size: 11px; }
  .panel { padding: 16px; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .search { width: 100%; }
  .profile-row { align-items: flex-start; flex-wrap: wrap; }
  .profile-row-actions { width: 100%; padding-right: 56px; }
  .form-grid,.detail-grid { grid-template-columns: 1fr; }
  .full { grid-column: auto; }
  .qr-area { grid-template-columns: 1fr; text-align: center; }
  .qr-box { width: 250px; margin: auto; }
  .page-title { align-items: flex-start; flex-direction: column; }
  .public-shell { padding: 0 12px; margin: 17px auto; }
  .public-card { padding: 16px; }
  .public-top h1 { font-size: 22px; }
  .medical-grid { grid-template-columns: 1fr; }
  .full-item { grid-column: auto; }
  .emergency-banner { align-items: stretch; flex-direction: column; }
  .emergency-button { width: 100%; }
}
@media (max-width: 430px) {
  .brand small { font-size: 8px; }
  .header-tools { gap: 5px; }
  .prototype-tag { padding: 5px 7px; font-size: 9px; }
  .theme-toggle { min-height: 34px; padding: 5px 7px; }
  .theme-label { display: none; }
  .hero-symbol { display: none; }
  .section-heading { align-items: center; gap: 8px; }
  .section-heading h2 { font-size: 20px; }
  .emergency-button { font-size: 16px; }
}
