@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;500;600;700;800&display=swap');

:root {
    --teal: #0f766e;
    --mint: #2dd4bf;
    --cyan: #06b6d4;
    --blue: #2563eb;
    --pink: #fb7185;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #dbeafe;
    --soft: #eaf7f6;
    --bg: #eef6f8;
    --card: #ffffff;
    --success: #22c55e;
    --danger: #ef4444;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08)
}

* {
    box-sizing: border-box
}

html {
    scroll-behavior: smooth
}

body {
    margin: 0;
    font-family: 'Sarabun', system-ui, sans-serif;
    background: linear-gradient(135deg, #eefcf9 0%, #f6fbff 42%, #eef4f8 100%);
    color: var(--ink)
}

body:before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 12% 8%, rgba(45, 212, 191, .24), transparent 26%), radial-gradient(circle at 92% 20%, rgba(37, 99, 235, .13), transparent 26%), radial-gradient(circle at 75% 92%, rgba(251, 113, 133, .12), transparent 26%);
    z-index: -1
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 18px;
    padding: 18px
}

.sidebar {
    position: sticky;
    top: 18px;
    height: calc(100vh - 36px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: rgba(255, 255, 255, .72);
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 26px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    overflow-y: auto;
    scrollbar-width: thin
}

.sidebar-visit-card {
  margin-top: auto;
  padding: 14px 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(20,184,166,.25);
  box-shadow: 0 10px 25px rgba(15,23,42,.08);
  text-align: center;
}

.sidebar-visit-card span {
  display: block;
  font-size: 12px;
  color: #64748b;
  font-weight: 700;
}

.sidebar-visit-card strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
  color: #0f766e;
  line-height: 1;
}

.sidebar-visit-card small,
.visit-mini {
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.visit-mini {
  margin-top: 8px;
}

.brand-card {
    text-decoration: none;
    color: #fff;
    background: linear-gradient(145deg, #0f766e, #0891b2 62%, #2563eb);
    border-radius: 20px;
    padding: 12px 12px;
    display: flex;
    gap: 10px;
    align-items: center;
    box-shadow: 0 12px 26px rgba(15, 118, 110, .22)
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: rgba(255, 255, 255, .2);
    display: grid;
    place-items: center;
    font-size: 18px;
    font-weight: 900;
    overflow: hidden
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 5px
}

.brand-card strong {
    font-size: 15px;
    line-height: 1.15
}

.nav-btn {
    white-space: normal;
    text-decoration: none;
    color: var(--ink);
    background: rgba(255, 255, 255, .9);
    border: 1px solid rgba(148, 163, 184, .38);
    border-radius: 16px;
    padding: 10px 12px;
    min-height: 48px;
    display: flex;
    align-items: center;
    text-align: left;
    font-size: 15px;
    line-height: 1.15;
    font-weight: 800;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .045);
    transition: .18s
}

.nav-btn:hover {
    transform: translateX(5px);
    border-color: var(--mint);
    color: var(--teal);
    background: #f0fdfa
}

.nav-btn.active {
    background: linear-gradient(135deg, #99f6e4, #dbeafe);
    border-color: var(--mint);
    color: #064e3b;
    box-shadow: 0 14px 28px rgba(20, 184, 166, .18)
}

.main-panel {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0
}

.topbar {
    min-height: 128px;
    background: linear-gradient(135deg, rgba(255, 255, 255, .96) 0%, rgba(248, 250, 252, .96) 55%, rgba(236, 254, 255, .96) 100%);
    border: 1px solid rgba(148, 163, 184, .30);
    border-radius: 30px;
    padding: 22px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative
}

.topbar:after {
    content: "";
    position: absolute;
    right: -80px;
    top: -110px;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(45, 212, 191, .18), rgba(37, 99, 235, .10))
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    z-index: 1
}

.hospital-logo-large {
    width: 72px;
    height: 72px;
    border-radius: 22px;
    background: #fff;
    border: 1px solid rgba(148, 163, 184, .28);
    box-shadow: 0 12px 24px rgba(15, 23, 42, .08);
    display: grid;
    place-items: center;
    overflow: hidden
}

.hospital-logo-large img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 7px
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--teal);
    font-weight: 900;
    letter-spacing: .02em
}

.topbar h1 {
    font-size: 34px;
    margin: 0;
    color: #082f49
}

.topbar p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 16px
}

.topbar-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    position: relative;
    z-index: 1
}

.clock {
    font-size: 32px;
    color: var(--pink);
    font-weight: 900;
    letter-spacing: .05em
}

.db-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 900;
    border: 1px solid rgba(148, 163, 184, .4);
    background: #fff
}

.status-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #f59e0b;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, .14)
}

.db-status.connected {
    color: #166534;
    border-color: rgba(34, 197, 94, .35);
    background: #f0fdf4
}

.db-status.connected .status-dot {
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, .16)
}

.db-status.disconnected {
    color: #991b1b;
    border-color: rgba(239, 68, 68, .35);
    background: #fef2f2
}

.db-status.disconnected .status-dot {
    background: var(--danger);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, .16)
}

.footer {
    font-size: 13px;
    text-align: right;
    color: #64748b;
    padding: 8px 0 0
}

.hero-card,
.empty-page,
.chart-card,
.kpi-card,
.link-card,
.filter-bar {
    background: rgba(255, 255, 255, .88);
    border: 1px solid rgba(148, 163, 184, .24);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px)
}

.hero-card {
    height: auto;
    border-radius: 30px;
    padding: 24px
}

.premium-home {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 20px
}

.home-intro {
    border-radius: 26px;
    padding: 22px 26px;
    background: linear-gradient(135deg, #ecfeff, #f8fafc);
    border: 1px solid rgba(45, 212, 191, .28)
}

.home-intro h2 {
    font-size: 28px;
    margin: 0;
    color: #082f49
}

.home-intro p {
    margin: 6px 0 0;
    color: var(--muted)
}

.banner-slider {
    position: relative;
    border-radius: 30px;
    height: 620px;
    overflow: hidden;
    background: #f8fafc;
    border: 1px solid rgba(148, 163, 184, .28);
}

.banner-image {
    width: 100%;
    height: 620px;
    object-fit: contain;
    object-position: center center;
    display: block;
    background: #ffffff;
    opacity: 0;
    transition: opacity .5s;
}

.hero-placeholder {
    height: 100%;
    min-height: 520px;
    border: 2px dashed rgba(20, 184, 166, .42);
    border-radius: 30px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
    text-align: center;
    background: linear-gradient(135deg, #f8fafc, #ecfeff);
    padding: 28px
}

.hero-placeholder h2 {
    font-size: 28px;
    color: #075985
}

.hero-placeholder p {
    font-size: 18px;
    color: var(--muted)
}

.banner-empty {
    position: absolute;
    inset: 0
}

.chev {
    font-size: 54px;
    color: var(--mint)
}

.filter-bar {
    display: flex;
    gap: 14px;
    align-items: end;
    justify-content: flex-end;
    border-radius: 24px;
    padding: 16px
}

.filter-bar label {
    font-weight: 900;
    color: var(--teal);
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px
}

.filter-bar input {
    border: 1px solid #5eead4;
    border-radius: 14px;
    padding: 11px 13px;
    font-family: inherit;
    background: #f8fafc;
    min-width: 150px;
    outline: none
}

.filter-bar input:focus {
    box-shadow: 0 0 0 4px rgba(45, 212, 191, .14)
}

.filter-bar button {
    background: linear-gradient(135deg, var(--teal), var(--cyan));
    border: 0;
    color: #fff;
    border-radius: 16px;
    padding: 13px 24px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 14px 28px rgba(20, 184, 166, .22);
    transition: .16s
}

.filter-bar button:hover {
    filter: brightness(.98);
    transform: translateY(-1px)
}

.filter-bar button:disabled {
    opacity: .65;
    cursor: wait;
    transform: none
}

.kpi-grid {
    display: grid;
    gap: 16px
}

.kpi-grid.five {
    grid-template-columns: repeat(5, 1fr)
}

.kpi-card {
    min-height: 126px;
    border-radius: 26px;
    padding: 18px;
    display: grid;
    align-content: space-between;
    position: relative;
    overflow: hidden
}

.kpi-card:before {
    content: "";
    position: absolute;
    right: -28px;
    top: -30px;
    width: 124px;
    height: 124px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(20, 184, 166, .16), rgba(37, 99, 235, .12))
}

.kpi-card:after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    height: 5px;
    width: 100%;
    background: linear-gradient(90deg, var(--teal), var(--cyan), var(--blue));
    opacity: .8
}

.kpi-card span {
    font-weight: 900;
    color: #0f172a;
    z-index: 1
}

.kpi-card strong {
    font-size: 39px;
    text-align: right;
    z-index: 1;
    color: var(--teal)
}

.kpi-card small {
    text-align: right;
    font-weight: 900;
    color: #475569;
    z-index: 1
}

.dashboard-grid {
    display: grid;
    gap: 18px
}

.dashboard-grid.two {
    grid-template-columns: 1fr 1fr
}

.chart-card {
    border-radius: 26px;
    padding: 20px;
    min-height: 400px
}

.chart-card.full {
    min-height: 390px
}

.chart-card h3 {
    margin: 0 0 16px;
    font-size: 20px;
    color: #0f172a
}

.chart-card canvas {
    width: 100% !important;
    max-height: 330px
}

.chart-card.full canvas {
    max-height: 320px
}

.note {
    margin: 0 0 8px;
    font-size: 13px;
    color: #64748b
}

.empty-page {
    min-height: calc(100vh - 170px);
    border-radius: 30px;
    padding: 64px
}

.empty-page h2 {
    font-size: 36px;
    margin: 0 0 12px;
    color: #075985
}

.empty-page p {
    font-size: 20px;
    color: var(--muted)
}

.links-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.link-card {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 110px;
  padding: 18px 20px;
  border-radius: 22px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(148,163,184,.25);
  box-shadow: 0 14px 35px rgba(15,23,42,.08);
  text-decoration: none;
  color: #0f172a;
  transition: .18s ease;
}

.link-card:hover {
  transform: translateY(-3px);
  border-color: rgba(20,184,166,.55);
  box-shadow: 0 18px 40px rgba(15,23,42,.13);
}

.link-icon-wrap {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(20,184,166,.16), rgba(59,130,246,.14));
  border: 1px solid rgba(20,184,166,.22);
  overflow: hidden;
}

.link-icon-img {
  width: 68px;
  height: 68px;
  object-fit: contain;
}

.link-icon-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #0f766e;
  font-size: 16px;
}

.link-content h3 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.35;
}

.link-content span {
  color: #0f766e;
  font-weight: 800;
  font-size: 14px;
}

.link-content strong {
    display: block;
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.35;
  color: #1e293b;
}

@media (max-width: 1200px) {
  .links-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

@media(max-width:1200px) {
    .app-shell {
        grid-template-columns: 1fr
    }

    .sidebar {
        position: static;
        height: auto;
        display: grid;
        grid-template-columns: repeat(6, 1fr)
    }

    .brand-card {
        grid-column: span 1
    }

    .dashboard-grid.two,
    .kpi-grid.five,
    .links-grid {
        grid-template-columns: 1fr 1fr
    }

    .topbar {
        height: auto
    }

    .filter-bar {
        justify-content: flex-start;
        flex-wrap: wrap
    }
}

@media(max-width:760px) {

    .dashboard-grid.two,
    .kpi-grid.five,
    .links-grid,
    .sidebar {
        grid-template-columns: 1fr
    }

    .app-shell {
        padding: 12px
    }

    .topbar {
        padding: 18px;
        align-items: flex-start;
        flex-direction: column
    }

    .clock {
        font-size: 26px
    }

    .topbar-right {
        align-items: flex-start
    }

    .topbar-title {
        align-items: flex-start
    }

    .hospital-logo-large {
        width: 56px;
        height: 56px
    }
 
}
/* Organization Structure Page */
.org-page {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.org-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 26px 30px;
    border-radius: 28px;
    background: linear-gradient(135deg, rgba(255, 255, 255, .96), rgba(236, 254, 255, .92));
    border: 1px solid rgba(148, 163, 184, .28);
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
}

.org-hero:after {
    content: "";
    position: absolute;
    right: -70px;
    top: -90px;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(45, 212, 191, .22), rgba(37, 99, 235, .12));
}

.org-hero h2 {
    margin: 0;
    font-size: 30px;
    color: #082f49;
}

.org-hero p:not(.eyebrow) {
    margin: 8px 0 0;
    color: var(--muted);
    max-width: 780px;
}

.org-count {
    position: relative;
    z-index: 1;
    min-width: 130px;
    text-align: center;
    padding: 16px 18px;
    border-radius: 24px;
    background: rgba(255, 255, 255, .8);
    border: 1px solid rgba(20, 184, 166, .25);
    box-shadow: 0 12px 24px rgba(15, 23, 42, .06);
}

.org-count strong {
    display: block;
    font-size: 38px;
    color: var(--teal);
    line-height: 1;
}

.org-count span {
    color: var(--muted);
    font-weight: 800;
}

.org-chart-wrap {
    padding: 26px;
    border-radius: 30px;
    background: rgba(255, 255, 255, .86);
    border: 1px solid rgba(148, 163, 184, .25);
    box-shadow: var(--shadow);
}

.org-level {
    display: flex;
    justify-content: center;
}

.org-connector {
    width: 3px;
    height: 34px;
    margin: 0 auto;
    background: linear-gradient(180deg, var(--teal), var(--blue));
    border-radius: 999px;
}

.person-card {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    border-radius: 26px;
    padding: 16px;
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(148, 163, 184, .25);
    box-shadow: 0 16px 34px rgba(15, 23, 42, .08);
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.person-card:before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 7px;
    background: linear-gradient(180deg, var(--teal), var(--cyan), var(--blue));
}

.person-card:hover {
    transform: translateY(-4px);
    border-color: rgba(20, 184, 166, .45);
    box-shadow: 0 22px 46px rgba(15, 23, 42, .11);
}

.person-card-director {
    max-width: 740px;
    width: 100%;
    padding: 20px 22px;
    background: linear-gradient(135deg, rgba(255,255,255,.98), rgba(236,254,255,.96));
}

.person-card-deputy {
    max-width: 620px;
    width: 100%;
}

.person-photo {
    flex: 0 0 auto;
    width: 112px;
    height: 132px;
    border-radius: 22px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: linear-gradient(135deg, #ccfbf1, #dbeafe);
    border: 1px solid rgba(148, 163, 184, .28);
    box-shadow: 0 12px 22px rgba(15, 23, 42, .08);
    color: var(--teal);
    font-weight: 900;
    font-size: 24px;
}

.person-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.person-photo span {
    display: none;
}

.person-photo.is-empty span {
    display: block;
}

.person-card-director .person-photo {
    width: 132px;
    height: 154px;
}

.person-info {
    min-width: 0;
}

.level-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 10px;
    background: #ecfeff;
    border: 1px solid rgba(20, 184, 166, .30);
    color: var(--teal);
    font-size: 13px;
    font-weight: 900;
    margin-bottom: 8px;
}

.person-info h3 {
    margin: 0;
    font-size: 22px;
    color: #0f172a;
}

.person-info .role {
    margin: 6px 0 0;
    color: #334155;
    font-weight: 800;
}

.person-info .unit {
    margin: 6px 0 0;
    color: var(--teal);
    font-weight: 900;
    line-height: 1.45;
}

.org-section-title {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 14px;
    margin: 26px 0 20px;
}

.org-section-title span {
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(15, 118, 110, .45), transparent);
}

.org-section-title h3 {
    margin: 0;
    font-size: 22px;
    color: #082f49;
}

.org-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.person-card-head {
    min-height: 170px;
}

.person-card-head .person-photo {
    width: 88px;
    height: 108px;
    border-radius: 18px;
    font-size: 20px;
}

.person-card-head .person-info h3 {
    font-size: 18px;
}

.person-card-head .person-info .role,
.person-card-head .person-info .unit {
    font-size: 14px;
}

.org-upload-note {
    padding: 22px;
    border-radius: 28px;
    background: rgba(255, 255, 255, .88);
    border: 1px dashed rgba(20, 184, 166, .42);
    box-shadow: var(--shadow);
}

.org-upload-note h3 {
    margin: 0 0 8px;
    color: #082f49;
}

.org-upload-note p {
    margin: 0 0 14px;
    color: var(--muted);
}

.org-upload-note code {
    background: #ecfeff;
    color: #0f766e;
    border: 1px solid rgba(20, 184, 166, .2);
    border-radius: 8px;
    padding: 2px 6px;
    font-weight: 900;
}

.org-filename-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.org-filename-grid div {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 16px;
    background: rgba(248, 250, 252, .86);
    border: 1px solid rgba(148, 163, 184, .18);
}

.org-filename-grid span {
    color: #334155;
    font-weight: 700;
    text-align: right;
}

@media(max-width:1400px) {
    .org-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media(max-width:900px) {
    .org-hero {
        flex-direction: column;
        align-items: flex-start;
    }
    .person-card,
    .person-card-director,
    .person-card-deputy {
        align-items: flex-start;
    }
    .org-grid,
    .org-filename-grid {
        grid-template-columns: 1fr;
    }
}

@media(max-width:560px) {
    .person-card {
        flex-direction: column;
    }
    .person-photo,
    .person-card-director .person-photo,
    .person-card-head .person-photo {
        width: 100%;
        height: 220px;
    }
}


/* Compact sidebar patch */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(15, 118, 110, .25);
    border-radius: 999px;
}

.nav-btn small {
    display: block;
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
    margin-top: 2px;
}
