@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css");

:root {
  --bg: #f1f5f9;
  --sidebar-bg: #ffffff;
  --panel: #ffffff;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --accent-glow: 0 6px 16px rgba(37, 99, 235, 0.2);
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.08);
  
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  
  --sidebar-width: 280px;
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  width: 100%;
  max-width: 100%;
}

body {
  margin: 0; min-height: 100vh;
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  width: 100%;
  max-width: 100%;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ----------------- LOGIN SCREEN ----------------- */
.login-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: var(--bg);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(37, 99, 235, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 90% 80%, rgba(37, 99, 235, 0.04) 0%, transparent 50%);
}
.login-card {
  width: min(92vw, 480px); padding: 48px;
  border: 1px solid var(--line); border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  text-align: center; position: relative; overflow: hidden;
}
.login-card::before {
  content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 4px;
  background: var(--accent);
}
.login-brand p.eyebrow, .eyebrow { font-weight: 700; color: var(--accent); margin: 0 0 12px; font-size: 2.55rem; text-transform: uppercase; letter-spacing: 0.05em; }
.login-brand h1 { font-size: 1.8rem; font-weight: 700; margin: 0 0 12px; letter-spacing: -0.02em; color: var(--text); line-height: 1.2; }
.login-brand p:last-child { color: var(--muted); font-size: 0.95rem; margin: 0; font-weight: 500; }

.login-ip-panel {
  display: flex; justify-content: space-between; align-items: center; padding: 16px 20px;
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: var(--radius-md); font-size: 0.9rem; margin-top: 32px;
}
.login-ip-panel span { color: var(--muted); font-weight: 500; }
.login-ip-panel strong { color: var(--text); font-weight: 700; font-size: 1rem; }

.app-download-panel {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}
.app-download-panel p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}
.app-download-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.app-download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: #f8fafc;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s;
}
.app-download-button:hover {
  border-color: #94a3b8;
  background: #ffffff;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.app-download-button svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  fill: currentColor;
}
.app-download-button.android { color: #15803d; }
.app-download-button.ios { color: #111827; }
.app-install-status {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  font-weight: 600;
}
.app-install-guide {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.5;
  text-align: left;
  font-weight: 600;
}

.login-actions { display: flex; gap: 12px; margin-top: 32px; justify-content: center; flex-wrap: wrap; }
.password-login-panel { display: grid; gap: 20px; max-height: 0; opacity: 0; overflow: hidden; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); text-align: left; }
.password-login-panel.is-open { max-height: 600px; opacity: 1; margin-top: 24px; overflow: visible; }

/* ----------------- BUTTONS & INPUTS ----------------- */
button, input, select, textarea { font: inherit; }
input, select, textarea {
  width: 100%; padding: 12px 16px;
  background: #ffffff; border: 1px solid var(--line-strong);
  border-radius: var(--radius-md); color: var(--text);
  transition: all 0.2s; font-weight: 500;
}
input::placeholder, textarea::placeholder { color: #94a3b8; font-weight: 400; }
input:hover, select:hover, textarea:hover { border-color: #94a3b8; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.primary-button, .secondary-button, .ghost-button, .danger-button {
  padding: 12px 24px; border-radius: var(--radius-md);
  font-weight: 600; font-size: 0.95rem; cursor: pointer; transition: all 0.2s;
  border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center;
}
.primary-button {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.1);
}
.primary-button:hover:not(:disabled) { background: var(--accent-hover); box-shadow: var(--accent-glow); transform: translateY(-1px); }
.primary-button:active:not(:disabled) { transform: translateY(0); }

.secondary-button { background: #ffffff; color: var(--text); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.secondary-button:hover:not(:disabled) { background: #f8fafc; border-color: #94a3b8; }

.ghost-button { background: transparent; color: var(--muted); padding: 8px 16px; }
.ghost-button:hover:not(:disabled) { color: var(--text); background: #f1f5f9; }

.danger-button { background: #fef2f2; color: #ef4444; border-color: #fca5a5; }
.danger-button:hover:not(:disabled) { background: #fee2e2; }

button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ----------------- APP SHELL ----------------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-width) 1fr; min-height: 100vh; }
.mobile-app-bar { display: none; }

.sidebar {
  background: var(--sidebar-bg); border-right: 1px solid var(--line);
  padding: 40px 24px 24px; display: flex; flex-direction: column; gap: 40px;
  position: relative; z-index: 10; box-shadow: 1px 0 10px rgba(0,0,0,0.02);
}
.brand-card .eyebrow { font-size: 2.55rem; margin-bottom: 8px; }
.brand-card h1 { font-size: 1.15rem; margin: 0 0 6px; color: var(--text); line-height: 1.3; font-weight: 700; }
.brand-copy { color: var(--muted); font-size: 0.85rem; margin: 0; font-weight: 500; }

.tab-list { display: grid; gap: 6px; }
.tab-button {
  width: 100%; padding: 12px 16px; background: transparent; color: var(--muted);
  border: none; border-radius: var(--radius-md);
  text-align: left; font-weight: 600; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; gap: 12px; position: relative;
}
.tab-button:hover { background: #f8fafc; color: var(--text); }
.tab-button.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.session-card {
  margin-top: auto; padding: 20px; background: #f8fafc;
  border: 1px solid var(--line); border-radius: var(--radius-md);
}
.session-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 16px; }
.session-card dl { margin: 0; display: grid; gap: 12px; }
.session-card dt { font-size: 0.7rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;}
.session-card dd { margin: 4px 0 0; font-weight: 700; font-size: 0.95rem; color: var(--text); }

.content-panel {
  min-width: 0; padding: 48px; overflow-y: auto; position: relative;
}
.panel { display: none; min-width: 0; animation: fadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.panel.is-active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header { margin-bottom: 40px; }
.panel-header .eyebrow { color: var(--accent); font-size: 0.85rem; letter-spacing: 0.1em; margin: 0 0 8px; text-transform: uppercase; font-weight: 700;}
.panel-header h2 { font-size: 2.2rem; margin: 0; font-weight: 800; letter-spacing: -0.03em; color: var(--text); }

/* ----------------- LAYOUTS & CARDS ----------------- */
.home-layout, .two-column-layout, .schedule-layout, .split-layout {
  display: grid; gap: 24px; margin-top: 24px;
}
.home-layout, .two-column-layout { grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); }
.schedule-layout { grid-template-columns: minmax(0, 2.5fr) minmax(320px, 1fr); }
.split-layout { grid-template-columns: 1fr 1fr; }
.access-whitelist-layout { grid-template-columns: minmax(0, 3fr) minmax(360px, 2fr); }

.home-sidebar-stack, .schedule-side-stack { display: grid; gap: 24px; align-content: start; }
.schedule-side-stack { position: sticky; top: 24px; }

.surface-card, .info-card {
  background: var(--panel); 
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 32px;
  max-width: 100%; min-width: 0; box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.surface-card:hover { box-shadow: var(--shadow-lg); }

.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; gap: 16px; }
.section-title h3 { margin: 0; font-size: 1.25rem; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }

.stack-list { display: grid; gap: 16px; }
.stack-item {
  padding: 20px; background: #ffffff; border: 1px solid var(--line);
  border-radius: var(--radius-md); transition: all 0.2s; position: relative;
  box-shadow: var(--shadow-sm);
}
.stack-item:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.stack-item h4 { margin: 0 0 8px; color: var(--text); font-weight: 700; font-size: 1.05rem; }
.stack-item p { margin: 0; color: var(--muted); font-size: 0.95rem; line-height: 1.6; font-weight: 500;}

/* ----------------- TABLES ----------------- */
.table-wrapper { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); background: #ffffff; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 16px 20px; border-bottom: 1px solid var(--line); }
th { background: #f8fafc; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
tbody tr { transition: all 0.2s; }
tbody tr:hover { background: #f1f5f9; }
tr:last-child td { border-bottom: none; }

.whitelist-table-wrapper {
  max-height: 360px;
  overflow: auto;
}

.whitelist-table-wrapper thead th {
  position: sticky;
  top: 0;
  z-index: 4;
}

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

.row-actions .primary-button,
.row-actions .danger-button {
  padding: 7px 12px;
  font-size: 0.8rem;
}

/* ----------------- FORMS ----------------- */
form.entry-form { display: grid; gap: 24px; }
label { display: grid; gap: 8px; }
label span { font-size: 0.9rem; color: var(--text); font-weight: 600; }
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.form-status { font-size: 0.9rem; color: var(--accent); min-height: 1.5em; margin-top: 8px; font-weight: 600;}

/* ----------------- UTILITIES ----------------- */
.is-hidden { display: none !important; }
.readonly-copy { color: var(--muted); font-size: 0.95rem; margin-bottom: 20px; line-height: 1.6; font-weight: 500;}
.notice-card { background: #fffbeb; border: 1px solid #fde68a; color: #b45309; padding: 16px 20px; border-radius: var(--radius-md); margin-bottom: 24px; font-weight: 600;}
.admin-only {} 

/* ----------------- CALENDAR OVERRIDES ----------------- */
.home-calendar-grid { display: grid; grid-template-columns: 1fr; gap: 24px; }
.calendar-group { display: grid; gap: 16px; }
.calendar-group h4 { margin: 0; color: var(--text); font-size: 1.1rem; font-weight: 700; }
.calendar-slot { max-width: 100%; min-height: 400px; border-radius: var(--radius-md); border: 1px solid var(--line); background: #ffffff; overflow: hidden; box-shadow: var(--shadow-sm); }
.calendar-slot.large { min-height: 500px; }
.home-calendar-panel .calendar-slot.large { min-height: 600px; }
.schedule-calendar-card .calendar-slot.large { min-height: 700px; }
.calendar-slot.is-fullcalendar { padding: 16px; border-style: solid; background: #ffffff; }

.fc { font-family: inherit; color: var(--text); }
.fc .fc-toolbar-title { font-size: 1.25rem; font-weight: 800; color: var(--text); }
.fc .fc-button { background: #ffffff; border: 1px solid var(--line-strong); color: var(--text); text-transform: capitalize; padding: 8px 16px; transition: all 0.2s; font-weight: 600; box-shadow: var(--shadow-sm); }
.fc .fc-button:hover { background: #f8fafc; border-color: #94a3b8; }
.fc .fc-button-active { background: #f1f5f9 !important; color: var(--accent) !important; border-color: var(--line-strong) !important; box-shadow: inset 0 2px 4px rgba(0,0,0,0.05); }
.fc .fc-col-header-cell-cushion, .fc .fc-daygrid-day-number { color: var(--text); padding: 8px; text-decoration: none; font-weight: 600; }
.fc-theme-standard td, .fc-theme-standard th { border-color: var(--line) !important; }
.fc .fc-event { border: none; background: var(--accent); padding: 3px 6px; border-radius: 4px; font-size: 0.85rem; font-weight: 600; cursor: pointer; color: #fff; box-shadow: 0 1px 3px rgba(37,99,235,0.3); }
.fc .fc-event:hover { opacity: 0.9; }
.fc .fc-list-event:hover td { background: #f1f5f9; }

/* Calendar Editor Specifics */
.calendar-editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.calendar-editor-grid-tight { align-items: end; }
.calendar-color-field { display: grid; gap: 12px; }
.calendar-color-field span { font-weight: 600; color: var(--text); font-size: 0.9rem; }
.calendar-color-palette { display: flex; gap: 10px; flex-wrap: wrap; }
.color-chip { width: 32px; height: 32px; border-radius: 50%; cursor: pointer; border: 2px solid #ffffff; background: var(--chip-color, var(--accent)); transition: all 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.color-chip.is-default { background: linear-gradient(135deg, #3b82f6 0 50%, #93c5fd 50% 100%); }
.color-chip.is-selected { transform: scale(1.15); box-shadow: 0 0 0 2px var(--accent), 0 2px 6px rgba(0,0,0,0.2); }

/* Calendar Detail Panel */
.calendar-detail-panel {
  position: absolute; top: 60px; right: 24px; width: 340px; background: #ffffff;
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px;
  box-shadow: var(--shadow-lg); z-index: 100;
}
.calendar-detail-header { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.calendar-detail-body { display: grid; gap: 16px; }
.calendar-detail-title { margin: 0; font-size: 1.4rem; font-weight: 700; color: var(--text); line-height: 1.3; }
.calendar-detail-date { margin: 0; font-size: 0.95rem; color: var(--muted); font-weight: 500; }
.calendar-detail-label { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 0.85rem; font-weight: 600; }
.calendar-detail-label::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--detail-label-bg, var(--accent)); }

/* ----------------- ATTENDANCE ----------------- */
.attendance-status-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.attendance-week-select-label { display: grid; gap: 8px; min-width: 240px; }
.attendance-week-select-label select { padding: 10px 14px; }
.attendance-table-wrapper { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); }
.attendance-table { min-width: 900px; table-layout: fixed; }
.attendance-table th:first-child, .attendance-table td:first-child { width: 140px; }
.attendance-day-heading { display: grid; gap: 6px; }
.attendance-day-name { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.attendance-day-date { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.attendance-day-type-combo { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 18px; gap: 4px; }
.attendance-day-type-toggle { min-height: 24px; padding: 0; border: 1px solid var(--line-strong); border-radius: 5px; background: #ffffff; color: var(--text); cursor: pointer; font-size: 0.55rem; font-weight: 600; }
.attendance-day-type-menu { position: absolute; z-index: 20; top: calc(100% + 4px); right: 0; left: 0; display: grid; gap: 2px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: #ffffff; box-shadow: var(--shadow-lg); }
.attendance-day-type-menu[hidden] { display: none; }
.attendance-day-type-menu button { min-height: 28px; padding: 6px 10px; border: 0; border-radius: 4px; background: transparent; color: var(--text); cursor: pointer; text-align: left; font-weight: 600; }
.attendance-day-type-menu button:hover { background: #f1f5f9; }

.attendance-table input { min-width: 0; min-height: 36px; padding: 8px 12px; font-size: 0.95rem; background: transparent; border: 1px solid transparent; color: var(--text); font-weight: 600; }
.attendance-table input:focus { background: #ffffff; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.attendance-table .attendance-day-heading input { min-height: 32px; padding: 6px 10px; font-size: 0.85rem; }
.attendance-row-label { font-weight: 700; color: var(--text); background: #f8fafc; }
.attendance-summary-space { margin-top: 32px; }
.attendance-summary-table { min-width: 1120px; }
.attendance-summary-cell { display: grid; gap: 6px; font-size: 0.9rem; color: var(--text); font-weight: 500; }
.attendance-empty-cell { color: var(--muted); text-align: center; }

/* ----------------- RESPONSIVE ----------------- */
@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { padding: 24px; flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: center; border-right: none; border-bottom: 1px solid var(--line); gap: 24px; }
  .brand-card { flex: 1; min-width: 200px; }
  .tab-list { display: flex; flex-wrap: wrap; gap: 8px; flex: 2; min-width: 300px; }
  .tab-button { width: auto; padding: 10px 16px; border-left: none; border-bottom: 2px solid transparent; border-radius: var(--radius-sm); }
  .tab-button.is-active { border-left: none; border-bottom: 2px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent-soft); }
  .session-card { display: none; }
  .content-panel { padding: 32px 24px; }
  .home-layout, .two-column-layout, .schedule-layout, .split-layout { grid-template-columns: 1fr; }
  .schedule-side-stack { position: static; }
  .calendar-detail-panel { position: static; width: auto; margin-top: 24px; }
}

@media (max-width: 720px) {
  html,
  body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .login-screen {
    align-items: start;
    padding: 16px;
  }

  .login-card {
    width: 100%;
    padding: 28px 20px;
    border-radius: var(--radius-lg);
  }

  .login-brand p.eyebrow,
  .eyebrow {
    font-size: 2rem;
  }

  .login-brand h1 {
    font-size: 1.35rem;
  }

  .app-download-actions {
    grid-template-columns: 1fr;
  }

  .login-ip-panel,
  .login-actions,
  .form-actions,
  .section-title,
  .attendance-status-row {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button,
  .ghost-button,
  .danger-button,
  input,
  select,
  textarea {
    min-height: 44px;
  }

  .form-actions > button,
  .login-actions > button,
  .section-title > button {
    width: 100%;
  }

  .app-shell {
    display: block;
    width: 100%;
    max-width: 100vw;
    padding: 0;
    gap: 0;
    min-height: 100dvh;
    overflow-x: hidden;
  }

  .mobile-app-shell .mobile-app-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: calc(54px + env(safe-area-inset-top));
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    backdrop-filter: blur(14px);
  }

  .mobile-app-bar strong {
    color: var(--accent);
    font-size: 0.95rem;
    letter-spacing: 0.08em;
  }

  .mobile-app-bar span {
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 800;
  }

  .sidebar {
    display: block;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .brand-card,
  .session-card {
    display: none;
  }

  .tab-list {
    position: fixed !important;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    width: 100vw;
    max-width: 100vw;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(72px, 1fr);
    min-width: 0;
    gap: 4px;
    overflow-x: auto;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -10px 24px rgba(15, 23, 42, 0.08);
    -webkit-overflow-scrolling: touch;
    transform: translateZ(0);
    will-change: transform;
  }

  .tab-button {
    width: 100%;
    min-height: 52px;
    padding: 8px 10px;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    border-radius: var(--radius-sm);
    border-bottom: 0;
    font-size: 0.8rem;
  }

  .tab-button.is-active {
    border-bottom: 0;
    background: var(--accent);
    color: #ffffff;
  }

  .content-panel {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    min-height: 100dvh;
    padding: calc(72px + env(safe-area-inset-top)) 12px calc(92px + env(safe-area-inset-bottom));
    border-radius: 0;
    overflow-x: hidden;
    overflow-y: visible;
  }

  .panel,
  #access-admin,
  .home-layout,
  .two-column-layout,
  .schedule-layout,
  .split-layout {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .panel-header {
    margin-bottom: 18px;
  }

  .panel-header h2 {
    font-size: 1.65rem;
    letter-spacing: 0;
  }

  .panel-header .eyebrow {
    font-size: 0.75rem;
  }

  .home-layout,
  .two-column-layout,
  .schedule-layout,
  .split-layout {
    gap: 16px;
    margin-top: 16px;
  }

  .home-sidebar-stack,
  .schedule-side-stack,
  .stack-list,
  form.entry-form {
    gap: 14px;
  }

  .surface-card,
  .info-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 16px 12px;
    border-radius: var(--radius-md);
    overflow: visible;
  }

  .surface-card:hover,
  .stack-item:hover {
    transform: none;
  }

  .section-title {
    gap: 10px;
    margin-bottom: 14px;
  }

  .section-title h3 {
    font-size: 1.08rem;
  }

  .stack-item {
    padding: 16px;
  }

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

  .calendar-slot,
  .calendar-slot.large,
  .home-calendar-panel .calendar-slot.large,
  .schedule-calendar-card .calendar-slot.large {
    min-height: 360px;
  }

  .calendar-slot.is-fullcalendar {
    padding: 10px;
  }

  .fc .fc-toolbar {
    align-items: stretch;
    gap: 8px;
  }

  .fc .fc-toolbar-title {
    font-size: 1rem;
    line-height: 1.3;
    text-align: center;
  }

  .fc .fc-button {
    padding: 7px 10px;
    font-size: 0.8rem;
  }

  .calendar-detail-panel {
    padding: 18px;
    border-radius: var(--radius-md);
  }

  .attendance-week-select-label {
    min-width: 0;
    width: 100%;
    gap: 4px;
  }

  .attendance-table-wrapper,
  .table-wrapper {
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .attendance-table-wrapper {
    scroll-snap-type: x proximity;
  }

  .attendance-table {
    min-width: 600px;
    table-layout: fixed;
  }

  .attendance-summary-table {
    min-width: 760px;
  }

  .attendance-table th:first-child,
  .attendance-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    box-shadow: 1px 0 0 var(--line);
  }

  .attendance-table th:first-child {
    background: #f8fafc;
  }

  .attendance-table td:first-child {
    background: #ffffff;
  }

  th,
  td {
    padding: 7px 6px;
    font-size: 0.72rem;
    line-height: 1.25;
  }

  .attendance-card {
    padding-top: 12px;
  }

  .attendance-status-row {
    gap: 6px;
    margin-bottom: 8px;
  }

  .attendance-status-row .form-status:empty {
    display: none;
    min-height: 0;
    margin: 0;
  }

  .attendance-table th:first-child,
  .attendance-table td:first-child {
    width: 64px;
  }

  .attendance-table th:not(:first-child),
  .attendance-table td:not(:first-child) {
    width: 76px;
  }

  .attendance-day-heading {
    gap: 2px;
  }

  .attendance-day-heading-editable {
    display: grid;
    grid-template-columns: auto auto minmax(42px, 1fr);
    align-items: center;
    column-gap: 3px;
  }

  .attendance-day-heading-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
  }

  .attendance-day-name,
  .attendance-day-date {
    font-size: 0.68rem;
    line-height: 1;
    white-space: nowrap;
  }

  .attendance-day-type-combo {
    grid-template-columns: minmax(0, 1fr) 16px;
    gap: 2px;
  }

  .attendance-day-type-toggle {
    min-height: 20px;
    font-size: 0.5rem;
  }

  .attendance-table .attendance-day-heading input {
    min-height: 20px;
    padding: 2px 3px;
    font-size: 0.58rem;
  }

  .attendance-row-label {
    font-size: 0.66rem;
    line-height: 1.15;
    word-break: keep-all;
    white-space: normal;
  }

  .attendance-table input {
    min-height: 30px;
    padding: 5px 4px;
    font-size: 0.72rem;
    text-align: center;
  }

  .attendance-day-type-menu {
    position: fixed;
    left: 14px;
    right: 14px;
    top: auto;
    bottom: calc(82px + env(safe-area-inset-bottom));
    max-height: 44vh;
    overflow-y: auto;
  }

  .todo-row {
    display: grid;
    gap: 12px;
  }

  .whitelist-table-wrapper {
    max-height: none;
    overflow: visible;
  }

  .whitelist-table-wrapper table,
  .whitelist-table-wrapper thead,
  .whitelist-table-wrapper tbody,
  .whitelist-table-wrapper tr,
  .whitelist-table-wrapper td {
    display: block;
    width: 100%;
  }

  .whitelist-table-wrapper thead {
    display: none;
  }

  .whitelist-table-wrapper tr {
    padding: 10px;
    border-bottom: 1px solid var(--line);
  }

  .whitelist-table-wrapper tr:last-child {
    border-bottom: 0;
  }

  .whitelist-table-wrapper td {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 8px;
    padding: 3px 0;
    border: 0;
    font-size: 0.76rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .whitelist-table-wrapper td::before {
    color: var(--muted);
    font-weight: 700;
  }

  .whitelist-table-wrapper td:nth-child(1)::before { content: "IP"; }
  .whitelist-table-wrapper td:nth-child(2)::before { content: "Role"; }
  .whitelist-table-wrapper td:nth-child(3)::before { content: "Label"; }
  .whitelist-table-wrapper td:nth-child(4)::before { content: "Note"; }
  .whitelist-table-wrapper td:nth-child(5)::before { content: "Action"; }

  .whitelist-table-wrapper .whitelist-group-row {
    padding: 0;
    background: #f8fafc;
  }

  .whitelist-table-wrapper .whitelist-group-row td {
    display: block;
    padding: 0;
  }

  .whitelist-table-wrapper .whitelist-group-row td::before {
    content: none;
  }

  .whitelist-group-toggle {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
  }

  .row-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .row-actions .primary-button,
  .row-actions .danger-button {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 0.72rem;
  }
}

@media (max-width: 420px) {
  .content-panel {
    padding-inline: 10px;
  }

  .surface-card,
  .info-card {
    padding-inline: 12px;
  }

  .tab-list {
    grid-auto-columns: minmax(66px, 1fr);
    padding-inline: 8px;
  }

  .tab-button {
    font-size: 0.76rem;
    padding-inline: 8px;
  }

  .panel-header h2 {
    font-size: 1.45rem;
  }

  .calendar-slot,
  .calendar-slot.large,
  .home-calendar-panel .calendar-slot.large,
  .schedule-calendar-card .calendar-slot.large {
    min-height: 380px;
  }
}
