* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f8fafc;
  color: #0f172a;
}

button,
input,
select,
textarea {
  font: inherit;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}

.sidebar {
  background: #fff;
  border-right: 1px solid #e2e8f0;
  padding: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: #0f172a;
  color: #fff;
  font-weight: 900;
}

.brand-title {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: #64748b;
  font-weight: 700;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  width: 100%;
  text-align: left;
  border-radius: 16px;
  padding: 13px 14px;
  background: transparent;
  color: #475569;
  font-size: 14px;
  font-weight: 800;
}

.nav-item.active {
  background: #0f172a;
  color: #fff;
}

.nav-item:not(.active):hover {
  background: #f1f5f9;
}

.main {
  padding: 28px;
}

.header {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 28px;
  padding: 24px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  box-shadow: 0 10px 35px rgba(15, 23, 42, .05);
}

.kicker {
  margin: 0 0 8px;
  color: #047857;
  font-size: 13px;
  font-weight: 900;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 36px);
  letter-spacing: -.05em;
  line-height: 1.15;
}

.lead {
  margin: 10px 0 0;
  color: #64748b;
  line-height: 1.8;
  font-size: 14px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  font-weight: 900;
  cursor: pointer;
}

.btn-primary {
  background: #059669;
  color: #fff;
}

.btn-dark {
  background: #0f172a;
  color: #fff;
}

.btn-light {
  background: #f1f5f9;
  color: #0f172a;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .04);
}

.stat-label {
  margin: 0;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

.stat-value {
  margin: 8px 0 0;
  font-size: 30px;
  font-weight: 950;
  letter-spacing: -.04em;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 20px;
}

.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 28px;
  padding: 22px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .04);
  margin-bottom: 20px;
}

.card-title {
  margin: 0;
  font-size: 19px;
  font-weight: 950;
}

.card-sub {
  margin: 6px 0 18px;
  color: #64748b;
  line-height: 1.7;
  font-size: 13px;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

.label {
  color: #334155;
  font-size: 13px;
  font-weight: 900;
}

.required {
  margin-left: 5px;
  color: #dc2626;
  font-size: 11px;
  font-weight: 950;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  border-radius: 16px;
  padding: 12px 14px;
  outline: none;
}

.textarea {
  min-height: 110px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 4px #d1fae5;
}

.preview {
  background: #f8fafc;
  border-radius: 22px;
  padding: 18px;
}

.preview-label {
  margin: 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
}

.preview-main {
  margin: 6px 0 0;
  font-size: 22px;
  font-weight: 950;
}

.badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.badge {
  border-radius: 999px;
  padding: 6px 10px;
  background: #ecfdf5;
  color: #047857;
  font-size: 12px;
  font-weight: 900;
}

.badge.dark {
  background: #0f172a;
  color: #fff;
}

.facility-list {
  display: grid;
  gap: 10px;
}

.facility-item {
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  padding: 14px;
}

.facility-name {
  margin: 0;
  font-weight: 950;
}

.facility-meta {
  margin: 5px 0 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.item-bottom {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.small-chip {
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 900;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }
.main {
    padding: 16px;
  }

  .header {
    display: block;
    border-radius: 24px;
  }

  .actions {
    margin-top: 16px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

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

  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* === mobile operation upgrade === */
.collapse-head {
  width: 100%;
  border: 0;
  background: transparent;
  color: #0f172a;
  padding: 0;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 19px;
  font-weight: 950;
  text-align: left;
  cursor: pointer;
}

.collapse-state {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
}

.card.is-collapsed > :not(.collapse-head):not(.card-title) {
  display: none;
}

.field.invalid .input,
.field.invalid .select,
.field.invalid .textarea {
  border-color: #ef4444;
  box-shadow: 0 0 0 4px #fee2e2;
}

.field-error {
  color: #dc2626;
  font-size: 12px;
  font-weight: 800;
}

.mobile-actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: none;
  gap: 10px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .94);
  border-top: 1px solid #e2e8f0;
  backdrop-filter: blur(14px);
  box-shadow: 0 -10px 30px rgba(15, 23, 42, .08);
}

.mobile-actionbar .btn {
  flex: 1;
  min-height: 48px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  z-index: 60;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 28px));
  border-radius: 18px;
  padding: 14px 16px;
  background: #0f172a;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 15px 45px rgba(15, 23, 42, .25);
  display: none;
}

.toast.show {
  display: block;
}

.empty-result {
  display: none;
  color: #64748b;
  background: #f8fafc;
  border-radius: 16px;
  padding: 14px;
  font-size: 13px;
  font-weight: 800;
}

.empty-result.show {
  display: block;
}

@media (max-width: 980px) {
  body {
    padding-bottom: 86px;
  }

  .mobile-actionbar {
    display: flex;
  }

  .header .actions {
    display: none;
  }
}

.zip-message {
  margin-top: 6px;
  min-height: 18px;
  font-size: 12px;
  font-weight: 800;
  color: #64748b;
}

.zip-message[data-type="loading"] {
  color: #0369a1;
}

.zip-message[data-type="success"] {
  color: #047857;
}

.zip-message[data-type="error"] {
  color: #b91c1c;
}

/* === name + kana layout polish === */
.name-kana-pair {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 14px;
  border: 1px solid #e8eef5;
  border-radius: 20px;
  background: #fbfdff;
}

.name-kana-pair .field {
  margin: 0;
}

.name-kana-pair .label {
  color: #1e293b;
}

.name-kana-pair .input {
  background: #ffffff;
}

.form-grid .field {
  min-width: 0;
}

.card {
  overflow: hidden;
}

.card-title {
  letter-spacing: -0.02em;
}

.card-sub {
  margin-bottom: 18px;
}

@media (max-width: 980px) {
  .name-kana-pair {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }
}

/* === facility type position polish === */
.facility-type-priority {
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px solid #e8eef5;
  border-radius: 20px;
  background: #fbfdff;
}

.facility-type-priority .select {
  background: #ffffff;
}

/* === organization type / postal layout polish === */
.organization-type-priority,
.facility-type-priority,
.postal-address-pair {
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px solid #e8eef5;
  border-radius: 20px;
  background: #fbfdff;
}

.postal-address-pair {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 14px;
}

.organization-type-priority .select,
.facility-type-priority .select,
.postal-address-pair .input {
  background: #ffffff;
}

@media (max-width: 980px) {
  .postal-address-pair {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }
}

/* === fix postal / address box balance === */
.postal-address-pair {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr !important;
  gap: 14px;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
}

.postal-address-pair .field {
  margin: 0;
}

.postal-address-pair .input {
  width: 100%;
  background: #ffffff;
}

@media (max-width: 980px) {
  .postal-address-pair {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
}

/* === organization phone / email layout polish === */
.phone-email-pair {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.phone-email-pair .field {
  margin: 0;
}

@media (max-width: 980px) {
  .phone-email-pair {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* === final postal / address size fix === */
.postal-address-pair {
  grid-column: 1 / -1;
  display: grid !important;
  grid-template-columns: 180px minmax(0, 1fr) !important;
  gap: 14px !important;
  align-items: start !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
}

.postal-address-pair .field {
  margin: 0 !important;
  min-width: 0;
}

.postal-address-pair .input {
  width: 100%;
  min-height: 46px;
  height: 46px;
  background: #ffffff;
}

.postal-address-pair + .zip-message {
  grid-column: 1 / -1;
  margin-top: -4px;
  margin-bottom: 2px;
  padding-left: 2px;
}

@media (max-width: 980px) {
  .postal-address-pair {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .postal-address-pair .input {
    height: 48px;
  }
}

/* MEDILINK_ACTION_BUTTON_SPACING */
.facility-item .item-bottom {
  margin-bottom: 10px;
}

.facility-item .item-bottom + a.btn,
.facility-item .item-bottom + .btn,
.facility-item a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  margin-top: 12px;
  line-height: 1.2;
  clear: both;
}

.facility-item .btn + .btn {
  margin-left: 8px;
}

@media (max-width: 640px) {
  .facility-item a.btn,
  .facility-item .btn {
    width: 100%;
    margin-left: 0;
  }
}

/* MEDILINK_HEADER_BUTTON_BALANCE */
.header {
  align-items: center;
  gap: 18px;
}

.header > .btn,
.header > a.btn,
.header > button.btn,
.header .no-print > .btn,
.header .no-print > a.btn,
.header .no-print > button.btn {
  width: auto !important;
  min-width: 118px !important;
  max-width: 220px !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 18px !important;
  border-radius: 14px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
  font-size: 14px !important;
}

.header > .btn.btn-primary,
.header > a.btn.btn-primary,
.header > button.btn.btn-primary {
  box-shadow: none;
}

@media (max-width: 760px) {
  .header {
    align-items: stretch;
  }

  .header > .btn,
  .header > a.btn,
  .header > button.btn,
  .header .no-print > .btn,
  .header .no-print > a.btn,
  .header .no-print > button.btn {
    width: 100% !important;
    max-width: none !important;
  }
}

/* MEDILINK_ROLE_THEME_ADMIN */
:root {
  --role-main: #0f172a;
  --role-main-2: #111827;
  --role-accent: #d4a017;
  --role-accent-soft: #fff7d6;
  --role-border: #f3d675;
}

body {
  background:
    radial-gradient(circle at top right, rgba(212,160,23,.16), transparent 32%),
    linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.sidebar {
  background: linear-gradient(180deg, #020617 0%, #0f172a 100%) !important;
}

.brand-mark {
  background: linear-gradient(135deg, #facc15, #b45309) !important;
  color: #111827 !important;
  box-shadow: 0 12px 30px rgba(212,160,23,.28);
}

.brand-title,
.brand-sub {
  color: #fff !important;
}

.nav-item {
  color: rgba(255,255,255,.76) !important;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(250,204,21,.16) !important;
  color: #fff !important;
  border-color: rgba(250,204,21,.38) !important;
}

.kicker {
  color: #b45309 !important;
}

.btn-primary {
  background: linear-gradient(135deg, #111827, #d4a017) !important;
  border-color: #d4a017 !important;
  color: #fff !important;
}

.stat,
.card {
  border-color: rgba(212,160,23,.18) !important;
}

.stat-value {
  color: #111827 !important;
}

.small-chip {
  background: #fff7d6 !important;
  color: #854d0e !important;
  border-color: #f3d675 !important;
}

.notice-card {
  background: linear-gradient(135deg, #fff7d6, #ffffff) !important;
  border-color: #d4a017 !important;
}

/* MEDILINK_BRAND_BY_SEED */
.brand-title {
  font-size: 15px !important;
  letter-spacing: .02em !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
}

.brand .brand-sub {
  display: none !important;
}

/* MEDILINK_LOGIN_BRAND_POLISH */
.login-card .brand-title,
.login-panel .brand-title,
.auth-card .brand-title,
.brand-title {
  white-space: nowrap;
}

.login-card h1,
.login-panel h1,
.auth-card h1 {
  letter-spacing: .02em;
}

.login-card .brand-sub,
.login-panel .brand-sub,
.auth-card .brand-sub {
  font-weight: 700;
  opacity: .82;
}

/* =========================================================

/* === facility_edit mobile polish start === */
@media (max-width: 760px), (hover: none) and (pointer: coarse) {

  #basic-info.card,
  #notification-settings.card,
  #medical-plan-settings.card {
    padding: 18px 14px !important;
    border-radius: 18px !important;
  }

  #basic-info .form-grid,
  #notification-settings .form-grid,
  #medical-plan-settings .form-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  #basic-info .field,
  #notification-settings .field,
  #medical-plan-settings .field,
  #basic-info label.field,
  #notification-settings label.field,
  #medical-plan-settings label.field {
    gap: 6px !important;
    min-width: 0 !important;
  }

  #basic-info .label,
  #notification-settings .label,
  #medical-plan-settings .label {
    letter-spacing: 0 !important;
    word-spacing: 0 !important;
    white-space: normal !important;
    line-height: 1.45 !important;
    font-size: 13px !important;
  }

  #basic-info .input,
  #notification-settings .input,
  #medical-plan-settings .input,
  #basic-info input:not([type="checkbox"]):not([type="radio"]),
  #notification-settings input:not([type="checkbox"]):not([type="radio"]),
  #medical-plan-settings input:not([type="checkbox"]):not([type="radio"]),
  #basic-info select,
  #notification-settings select,
  #medical-plan-settings select {
    width: 100% !important;
    min-height: 44px !important;
    height: auto !important;
    padding: 10px 12px !important;
    font-size: 16px !important;
    line-height: 1.4 !important;
    box-sizing: border-box !important;
  }

  #basic-info textarea.input,
  #notification-settings textarea.input,
  #medical-plan-settings textarea.input,
  #basic-info textarea,
  #notification-settings textarea,
  #medical-plan-settings textarea {
    width: 100% !important;
    min-height: 86px !important;
    padding: 10px 12px !important;
    font-size: 16px !important;
    line-height: 1.45 !important;
    box-sizing: border-box !important;
    resize: vertical !important;
  }

  #notification-settings .label:has(input[type="checkbox"]),
  #medical-plan-settings .label:has(input[type="checkbox"]) {
    display: flex !important;
    align-items: flex-start !important;
    gap: 8px !important;
    padding: 10px 12px !important;
    border: 1px solid #dbeafe !important;
    background: #f8fafc !important;
    border-radius: 12px !important;
    font-weight: 700 !important;
  }

  #notification-settings input[type="checkbox"],
  #medical-plan-settings input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    margin: 1px 2px 0 0 !important;
    flex: 0 0 auto !important;
  }

  #medical-plan-settings .section-head {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  #medical-plan-settings .section-head .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  #medical-plan-settings .small-chip {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    min-height: 36px !important;
    padding: 8px 10px !important;
    border-radius: 999px !important;
    white-space: nowrap !important;
  }

  .form-actions,
  .actions {
    gap: 10px !important;
  }

  .form-actions .btn,
  .actions .btn,
  button.btn {
    min-height: 44px !important;
  }
}
/* === facility_edit mobile polish end === */

/* === MediLink LINE notification setting UI === */
.line-setting-box {
  border: 1px solid #dbeafe;
  background: #f8fafc;
  border-radius: 14px;
  padding: 14px;
}

.line-help-box {
  margin-top: 10px;
  border: 1px dashed #bfdbfe;
  background: #ffffff;
  border-radius: 12px;
  padding: 10px;
}

.line-help-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
}

.line-user-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
  border-top: 1px solid #e5e7eb;
}

.line-user-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.line-user-code {
  display: block;
  width: 100%;
  font-size: 12px;
  line-height: 1.6;
  white-space: normal;
  word-break: break-all;
  user-select: all;
  color: #065f46;
}

.line-user-meta {
  font-size: 12px;
  color: #64748b;
}

@media (max-width: 760px), (hover: none) and (pointer: coarse) {
  .line-setting-box {
    padding: 12px !important;
  }

  .line-user-code {
    font-size: 11px;
  }
}

/* MEDILINK_COLLAPSIBLE_CARDS_20260526 */
.card.ml-collapsible {
  position: relative;
}
.card.ml-collapsible > .card-title {
  cursor: pointer;
  padding-right: 56px;
}
.ml-card-toggle {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(20, 80, 70, .18);
  border-radius: 999px;
  background: #eefbf7;
  color: #0f6b59;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}
.card.ml-collapsed > :not(.card-title):not(.ml-card-toggle) {
  display: none !important;
}

/* MEDILINK_COLLAPSIBLE_SECTION_HEAD_FIX_20260526 */
.card.ml-collapsible > .section-head .card-title {
  cursor: pointer;
  padding-right: 56px;
}
.card.ml-collapsed > :not(.card-title):not(.section-head):not(.ml-card-toggle) {
  display: none !important;
}
.card.ml-collapsed > .section-head .card-sub,
.card.ml-collapsed > .section-head .btn {
  display: none !important;
}

/* MEDILINK_NOTIFICATION_DELIVERIES_20260526 */
.notify-deliveries {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #dbeafe;
  background: #f8fbff;
  border-radius: 12px;
}
.notify-delivery-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
  color: #0f766e;
}
.notify-delivery-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  padding: 7px 0;
  border-top: 1px solid #e5e7eb;
  font-size: 12px;
  color: #334155;
  word-break: break-word;
}
.notify-delivery-row:first-of-type {
  border-top: 0;
}

/* MEDILINK_ADMIN_GLOBAL_STATS_HORIZONTAL_20260527 */
@media (max-width: 980px) {
  .stats {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    overflow-x: auto !important;
    padding-bottom: 6px !important;
    margin-bottom: 12px !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .stats .stat {
    flex: 0 0 31% !important;
    min-width: 104px !important;
    padding: 10px 8px !important;
    border-radius: 16px !important;
    min-height: 72px !important;
  }

  .stats .stat-label {
    font-size: 10px !important;
    line-height: 1.35 !important;
    margin: 0 0 5px !important;
    white-space: nowrap !important;
  }

  .stats .stat-value,
  .stats .notice-count {
    font-size: 22px !important;
    line-height: 1.1 !important;
    margin: 0 !important;
    white-space: nowrap !important;
  }
}

/* MEDILINK_NURSE_EDIT_CARD_34_MOBILE_MATCH_12_20260529 */
@media (max-width: 760px), (hover: none) and (pointer: coarse) {
  #related-schedules.card,
  #nurse-notification-logs.card {
    padding: 18px 14px !important;
    border-radius: 18px !important;
  }
}
