/* Apple-like UI refinement layer. Kept separate so the system look can be updated without touching module logic. */
:root {
  --apple-blur: saturate(180%) blur(22px);
  --apple-card-radius: 22px;
  --apple-soft-border: rgba(255, 255, 255, .12);
}
body { letter-spacing: -0.01em; }
.sys-card, .auth-card, .sys-table-wrapper {
  border-radius: var(--apple-card-radius) !important;
  box-shadow: 0 18px 50px rgba(0,0,0,.16) !important;
}
.sys-card { backdrop-filter: var(--apple-blur); -webkit-backdrop-filter: var(--apple-blur); }
.sys-btn, .sys-input, .sys-select, .sys-textarea, .sys-pill, .apple-tab { border-radius: 14px !important; }
.sys-btn { font-weight: 700; }
.page-title { font-size: clamp(1.45rem, 2vw, 2.2rem); }
.sidebar { backdrop-filter: var(--apple-blur); -webkit-backdrop-filter: var(--apple-blur); }
.nav-item { border-radius: 14px !important; }
.sys-top-bar { gap: 16px; }
.update-dropzone {
  border: 1px dashed var(--sys-border);
  border-radius: 18px;
  padding: 18px;
  background: rgba(0,122,255,.06);
}
.sys-filter-line,
.sys-bulk-line {
  width: 100%;
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--sys-border);
  border-radius: 22px;
  background: var(--sys-glass-bg);
  box-shadow: var(--sys-card-shadow);
  margin-bottom: 18px;
}
.sys-filter-line { flex-wrap: nowrap; overflow-x: auto; }
.sys-filter-field { flex: 1 0 var(--field-width, minmax(140px, 1fr)); min-width: 138px; }
.sys-filter-field label { display:block; margin: 0 0 6px; color: var(--sys-text-muted); font-size:.72rem; text-transform:uppercase; font-weight:800; letter-spacing:.08em; }
.sys-filter-actions, .bulk-actions { display:flex; align-items:center; gap:8px; flex: 0 0 auto; }
.sys-bulk-line { justify-content: space-between; align-items:center; }
.bulk-counter { color: var(--sys-text-muted); font-size:.9rem; font-weight:700; }
.bulk-counter i { color: var(--sys-blue); margin-right:6px; }
.sys-notice { padding:14px 18px !important; display:flex; align-items:center; gap:12px; }
[data-theme="light"] .sys-card, [data-theme="light"] .auth-card { box-shadow: 0 18px 45px rgba(15, 23, 42, .08) !important; }
[data-theme="light"] .sys-filter-line, [data-theme="light"] .sys-bulk-line { background: rgba(255,255,255,.92); }
@media (max-width: 900px) {
  .sys-filter-line { flex-wrap: wrap; }
  .sys-filter-field { flex: 1 1 100%; }
  .sys-filter-actions, .bulk-actions { width:100%; flex-wrap:wrap; }
  .sys-bulk-line { align-items:flex-start; flex-direction:column; }
}
@media (max-width: 768px) { .sys-card { padding: 18px !important; } }

/* System-wide branded action feedback layer */
.ics-toast-stack {
  position: fixed;
  top: 22px;
  right: 22px;
  width: min(420px, calc(100vw - 32px));
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}
.ics-toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 44px 1fr 28px;
  gap: 12px;
  align-items: center;
  padding: 14px 14px;
  border-radius: 22px;
  background: rgba(14, 23, 38, .82);
  color: #fff;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 22px 70px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.08);
  backdrop-filter: saturate(180%) blur(26px);
  -webkit-backdrop-filter: saturate(180%) blur(26px);
  transform-origin: top right;
  animation: icsToastIn .38s cubic-bezier(.2,.9,.2,1) both;
}
.ics-toast.is-leaving { animation: icsToastOut .24s ease both; }
.ics-toast-icon {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.08);
  font-size: 1.1rem;
}
.ics-toast-copy strong {
  display: block;
  font-size: .92rem;
  line-height: 1.15;
  letter-spacing: -.01em;
}
.ics-toast-copy span {
  display: block;
  margin-top: 4px;
  color: rgba(255,255,255,.74);
  font-size: .84rem;
  line-height: 1.35;
}
.ics-toast-close {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.65);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  transition: .2s ease;
}
.ics-toast-close:hover { background: rgba(255,255,255,.1); color: #fff; }
.ics-toast-success .ics-toast-icon { background: rgba(52,199,89,.16); color: #34C759; }
.ics-toast-danger .ics-toast-icon { background: rgba(255,59,48,.16); color: #FF3B30; }
.ics-toast-warning .ics-toast-icon { background: rgba(255,149,0,.16); color: #FF9500; }
.ics-toast-info .ics-toast-icon { background: rgba(0,122,255,.16); color: #5AC8FA; }
[data-theme="light"] .ics-toast {
  background: rgba(255,255,255,.88);
  color: #0F172A;
  border-color: rgba(15,23,42,.08);
  box-shadow: 0 22px 70px rgba(15,23,42,.14), inset 0 1px 0 rgba(255,255,255,.9);
}
[data-theme="light"] .ics-toast-copy span { color: #64748B; }
[data-theme="light"] .ics-toast-close { color: #64748B; }
[data-theme="light"] .ics-toast-close:hover { background: rgba(15,23,42,.06); color: #0F172A; }

.ics-modal-root,
.ics-loading-layer {
  position: fixed;
  inset: 0;
  z-index: 99998;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .26s ease;
}
.ics-modal-root.is-open,
.ics-loading-layer.is-open { opacity: 1; pointer-events: auto; }
.ics-modal-backdrop,
.ics-loading-layer::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(2, 8, 23, .62);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.ics-modal-card {
  position: relative;
  width: min(460px, calc(100vw - 34px));
  padding: 28px;
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(16, 26, 43, .94), rgba(9, 16, 29, .94));
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 32px 90px rgba(0,0,0,.36), inset 0 1px 0 rgba(255,255,255,.08);
  text-align: center;
  transform: translateY(16px) scale(.96);
  transition: transform .28s cubic-bezier(.2,.9,.2,1);
}
.ics-modal-root.is-open .ics-modal-card { transform: translateY(0) scale(1); }
.ics-modal-icon {
  width: 74px;
  height: 74px;
  margin: 0 auto 16px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: var(--sys-blue-gradient);
  color: #fff;
  font-size: 1.8rem;
  box-shadow: 0 14px 32px rgba(0,122,255,.26);
}
.ics-modal-kicker {
  color: var(--sys-text-muted);
  text-transform: uppercase;
  font-size: .7rem;
  letter-spacing: .18em;
  font-weight: 800;
  margin-bottom: 8px;
}
.ics-modal-card h3 {
  display: block;
  color: var(--sys-text-main);
  font-size: 1.38rem;
  margin: 0 0 10px;
  text-align: center;
}
.ics-modal-card p {
  color: var(--sys-text-muted);
  font-size: .98rem;
  line-height: 1.55;
  max-width: 360px;
  margin: 0 auto 24px;
}
.ics-modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ics-modal-actions .sys-btn { min-width: 132px; justify-content: center; }
[data-theme="light"] .ics-modal-backdrop,
[data-theme="light"] .ics-loading-layer::before { background: rgba(226,232,240,.68); }
[data-theme="light"] .ics-modal-card {
  background: rgba(255,255,255,.9);
  border-color: rgba(15,23,42,.08);
  box-shadow: 0 32px 90px rgba(15,23,42,.18), inset 0 1px 0 rgba(255,255,255,.9);
}

.ics-loading-card {
  position: relative;
  display: flex;
  gap: 16px;
  align-items: center;
  width: min(390px, calc(100vw - 38px));
  padding: 18px;
  border-radius: 26px;
  background: rgba(16, 26, 43, .88);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 28px 80px rgba(0,0,0,.30);
  backdrop-filter: saturate(180%) blur(26px);
  -webkit-backdrop-filter: saturate(180%) blur(26px);
  color: #fff;
  animation: icsModalPulse 1.8s ease-in-out infinite;
}
.ics-loading-orb {
  width: 54px;
  height: 54px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--sys-blue-gradient);
  box-shadow: 0 14px 32px rgba(0,122,255,.28);
  font-size: 1.35rem;
}
.ics-loading-card strong { display:block; font-size: .98rem; }
.ics-loading-card span { display:block; color: rgba(255,255,255,.68); font-size: .84rem; margin-top: 3px; }
[data-theme="light"] .ics-loading-card {
  background: rgba(255,255,255,.9);
  color: #0F172A;
  border-color: rgba(15,23,42,.08);
  box-shadow: 0 28px 80px rgba(15,23,42,.16);
}
[data-theme="light"] .ics-loading-card span { color: #64748B; }

.ics-inline-notice {
  animation: icsNoticeIn .36s cubic-bezier(.2,.9,.2,1) both;
  border-radius: 22px !important;
}
.ics-inline-notice strong { line-height: 1.35; }

button, .sys-btn, a, input, select, textarea { transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease; }
button:active, .sys-btn:active, a.sys-btn:active { transform: scale(.985); }
button[disabled], .sys-btn[disabled] { cursor: not-allowed; opacity: .58; }

@keyframes icsToastIn {
  from { opacity: 0; transform: translate3d(18px,-10px,0) scale(.96); filter: blur(4px); }
  to { opacity: 1; transform: translate3d(0,0,0) scale(1); filter: blur(0); }
}
@keyframes icsToastOut {
  to { opacity: 0; transform: translate3d(18px,-8px,0) scale(.96); filter: blur(4px); }
}
@keyframes icsNoticeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes icsModalPulse {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@media (max-width: 640px) {
  .ics-toast-stack { top: 12px; right: 12px; left: 12px; width: auto; }
  .ics-toast { grid-template-columns: 38px 1fr 26px; border-radius: 20px; padding: 12px; }
  .ics-toast-icon { width: 38px; height: 38px; border-radius: 14px; }
  .ics-modal-card { padding: 24px 18px; border-radius: 26px; }
  .ics-modal-actions { flex-direction: column-reverse; }
  .ics-modal-actions .sys-btn { width: 100%; }
}
.sys-notice {
  display: flex !important;
  align-items: center;
  gap: 14px;
}
.sys-notice-icon {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.sys-notice-copy { display: grid; gap: 2px; }
.sys-notice-copy strong { color: var(--sys-text-main); font-size: .95rem; }
.sys-notice-copy em { color: var(--sys-text-muted); font-style: normal; font-size: .9rem; }


/* =========================================================
   System-wide table + mobile polish
   - Every data table shows max 20 body rows, then scrolls inside the card.
   - Sticky headers remain visible while scrolling.
   - Mobile keeps all columns accessible with smooth horizontal scrolling.
========================================================= */
:root {
  --ics-table-visible-rows: 20;
  --ics-table-row-height: 58px;
  --ics-table-head-height: 58px;
  --ics-table-max-height: calc((var(--ics-table-visible-rows) * var(--ics-table-row-height)) + var(--ics-table-head-height));
}
.sys-table-wrapper,
.table-wrapper,
.table-scroll-block {
  width: 100%;
  max-width: 100%;
  overflow: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  position: relative;
}
.sys-table-wrapper.ics-table-scroll,
.table-wrapper.ics-table-scroll,
.table-scroll-block.ics-table-scroll {
  max-height: min(var(--ics-table-max-height), 74vh) !important;
}
.sys-table-wrapper.ics-table-scroll::after,
.table-wrapper.ics-table-scroll::after,
.table-scroll-block.ics-table-scroll::after {
  content: "Scroll to see more";
  position: sticky;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: rgba(255,255,255,.72);
  background: rgba(15,23,42,.64);
  border: 1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
  z-index: 8;
}
.sys-table-wrapper.ics-table-overflowing:hover::after,
.table-wrapper.ics-table-overflowing:hover::after,
.table-scroll-block.ics-table-overflowing:hover::after { opacity: 1; }
[data-theme="light"] .sys-table-wrapper.ics-table-scroll::after,
[data-theme="light"] .table-wrapper.ics-table-scroll::after,
[data-theme="light"] .table-scroll-block.ics-table-scroll::after {
  color: #334155;
  background: rgba(255,255,255,.82);
  border-color: rgba(15,23,42,.08);
}
.sys-table-wrapper table,
.table-wrapper table,
.table-scroll-block table {
  width: 100%;
  min-width: max(760px, 100%);
}
.sys-table-wrapper thead th,
.table-wrapper thead th,
.table-scroll-block thead th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: rgba(15,23,42,.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
[data-theme="light"] .sys-table-wrapper thead th,
[data-theme="light"] .table-wrapper thead th,
[data-theme="light"] .table-scroll-block thead th { background: rgba(248,250,252,.96); }
.sys-table-wrapper tbody tr,
.table-wrapper tbody tr,
.table-scroll-block tbody tr { min-height: var(--ics-table-row-height); }
.sys-table-wrapper td,
.table-wrapper td,
.table-scroll-block td,
.sys-table-wrapper th,
.table-wrapper th,
.table-scroll-block th {
  vertical-align: middle;
}
.ics-scroll-hint {
  display: none;
  margin: -8px 0 10px;
  color: var(--sys-text-muted);
  font-size: .8rem;
  font-weight: 700;
  gap: 6px;
  align-items: center;
}
.ics-scroll-hint i { color: var(--sys-blue); }

@media (max-width: 1024px) {
  .main-content { max-width: 100vw !important; }
  .content-wrapper { max-width: 100%; }
  .sys-top-bar { align-items: flex-start; }
  .sys-top-right { gap: 8px; }
  .sys-pill { max-width: 100%; }
}

@media (max-width: 768px) {
  :root {
    --ics-table-row-height: 52px;
    --ics-table-head-height: 52px;
  }
  body { overflow-x: hidden; }
  .main-content { padding: 14px !important; }
  .content-wrapper { width: 100%; overflow: visible; }
  .sys-card { padding: 16px !important; border-radius: 22px !important; overflow: hidden; }
  .sys-action-bar,
  .sys-filter-bar,
  .sys-filter-line,
  .sys-bulk-line {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    overflow: visible !important;
    padding: 12px !important;
  }
  .sys-filter-field,
  .sys-filter-actions,
  .bulk-actions,
  .sys-bulk-line > *,
  .sys-action-bar > *,
  .sys-filter-bar > * {
    min-width: 0 !important;
    width: 100% !important;
  }
  .sys-filter-actions,
  .bulk-actions,
  .flex-gap {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  .sys-input,
  .sys-select,
  .sys-textarea,
  .sys-btn,
  button,
  select,
  input[type="date"],
  input[type="search"] {
    max-width: 100%;
  }
  .sys-btn { min-height: 42px; padding-inline: 14px !important; }
  .page-title { font-size: clamp(1.45rem, 8vw, 2rem) !important; line-height: 1.1 !important; }
  .sys-top-bar { gap: 12px; margin-bottom: 16px; }
  .sys-top-right { width: 100%; display: grid; grid-template-columns: 1fr; }
  .sys-pill { width: 100%; justify-content: center; white-space: normal; text-align: center; }
  .kpi-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
  .kpi-val { font-size: 2.1rem !important; }
  .apple-tabs,
  .settings-tabs {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    justify-content: flex-start;
  }
  .apple-tab { flex: 0 0 auto; }
  .sys-table-wrapper,
  .table-wrapper,
  .table-scroll-block {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 18px !important;
    margin-inline: 0 !important;
  }
  .sys-table-wrapper.ics-table-scroll,
  .table-wrapper.ics-table-scroll,
  .table-scroll-block.ics-table-scroll {
    max-height: min(var(--ics-table-max-height), 68vh) !important;
  }
  .sys-table-wrapper table,
  .table-wrapper table,
  .table-scroll-block table {
    min-width: max-content !important;
    width: max-content !important;
  }
  .sys-table-wrapper th,
  .table-wrapper th,
  .table-scroll-block th,
  .sys-table-wrapper td,
  .table-wrapper td,
  .table-scroll-block td {
    padding: 12px 14px !important;
    font-size: .88rem !important;
    max-width: 260px;
    white-space: nowrap;
  }
  .sys-table-wrapper td,
  .table-wrapper td,
  .table-scroll-block td { overflow: hidden; text-overflow: ellipsis; }
  .sys-table-wrapper td:hover,
  .table-wrapper td:hover,
  .table-scroll-block td:hover { white-space: normal; overflow: visible; }
  .ics-scroll-hint { display: inline-flex; }
}

@media (max-width: 420px) {
  .main-content { padding: 10px !important; }
  .mobile-header { padding: 12px 14px !important; }
  .sys-card { padding: 14px !important; }
  .sys-btn { font-size: .9rem !important; }
  .sys-table-wrapper th,
  .table-wrapper th,
  .table-scroll-block th,
  .sys-table-wrapper td,
  .table-wrapper td,
  .table-scroll-block td {
    padding: 10px 12px !important;
    font-size: .84rem !important;
  }
}

@media print {
  .sys-table-wrapper,
  .table-wrapper,
  .table-scroll-block,
  .sys-table-wrapper.ics-table-scroll,
  .table-wrapper.ics-table-scroll,
  .table-scroll-block.ics-table-scroll {
    max-height: none !important;
    overflow: visible !important;
    box-shadow: none !important;
  }
  .sys-table-wrapper.ics-table-scroll::after,
  .table-wrapper.ics-table-scroll::after,
  .table-scroll-block.ics-table-scroll::after,
  .ics-scroll-hint { display: none !important; }
  .sys-table-wrapper table,
  .table-wrapper table,
  .table-scroll-block table { min-width: 0 !important; width: 100% !important; }
}


/* =========================================================
   ICS OCD POLISH: canonical tabs, messages, upload cards
   ========================================================= */
.apple-tabs,
.settings-tabs,
.sub-tabs,
.module-tabs,
.page-tabs,
.report-tabs,
.tab-bar {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  width: fit-content !important;
  max-width: 100% !important;
  margin: 0 0 24px 0 !important;
  padding: 7px !important;
  border-radius: 18px !important;
  border: 1px solid var(--sys-border) !important;
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.045)) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 12px 34px rgba(0,0,0,.08) !important;
  scrollbar-width: none !important;
  -webkit-overflow-scrolling: touch !important;
}
.apple-tabs::-webkit-scrollbar,
.settings-tabs::-webkit-scrollbar,
.sub-tabs::-webkit-scrollbar,
.module-tabs::-webkit-scrollbar,
.page-tabs::-webkit-scrollbar,
.report-tabs::-webkit-scrollbar,
.tab-bar::-webkit-scrollbar { display:none !important; }
.apple-tab,
.sub-tab,
.module-tab,
.page-tab,
.report-tab,
.tab-link {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  min-height: 40px !important;
  padding: 0 17px !important;
  border-radius: 13px !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--sys-text-muted) !important;
  font-size: .9rem !important;
  font-weight: 750 !important;
  letter-spacing: -.01em !important;
  text-decoration: none !important;
  white-space: nowrap !important;
  transition: transform .18s ease, background .18s ease, color .18s ease, box-shadow .18s ease !important;
}
.apple-tab:hover,
.sub-tab:hover,
.module-tab:hover,
.page-tab:hover,
.report-tab:hover,
.tab-link:hover {
  transform: translateY(-1px) !important;
  color: var(--sys-text-main) !important;
  background: rgba(127,127,127,.13) !important;
}
.apple-tab.active,
.apple-tab.is-active,
.sub-tab.active,
.sub-tab.is-active,
.module-tab.active,
.module-tab.is-active,
.page-tab.active,
.page-tab.is-active,
.report-tab.active,
.report-tab.is-active,
.tab-link.active,
.tab-link.is-active {
  color: #fff !important;
  background: var(--sys-blue-gradient) !important;
  box-shadow: 0 10px 24px rgba(0,122,255,.26), inset 0 1px 0 rgba(255,255,255,.20) !important;
}
[data-theme="light"] .apple-tabs,
[data-theme="light"] .settings-tabs,
[data-theme="light"] .sub-tabs,
[data-theme="light"] .module-tabs,
[data-theme="light"] .page-tabs,
[data-theme="light"] .report-tabs,
[data-theme="light"] .tab-bar {
  background: rgba(241,245,249,.86) !important;
  border-color: #D8DEE9 !important;
  box-shadow: inset 0 1px 0 #fff, 0 12px 30px rgba(15,23,42,.06) !important;
}
[data-theme="light"] .apple-tab,
[data-theme="light"] .sub-tab,
[data-theme="light"] .module-tab,
[data-theme="light"] .page-tab,
[data-theme="light"] .report-tab,
[data-theme="light"] .tab-link { color:#526071 !important; }
[data-theme="light"] .apple-tab:hover,
[data-theme="light"] .sub-tab:hover,
[data-theme="light"] .module-tab:hover,
[data-theme="light"] .page-tab:hover,
[data-theme="light"] .report-tab:hover,
[data-theme="light"] .tab-link:hover { background:#fff !important; color:#0F172A !important; }

.ics-toast-stack { z-index: 2147483600 !important; }
.ics-modal-root, .ics-loading-layer { z-index: 2147483599 !important; }
.ics-inline-notice,
.sys-notice,
.alert,
.notice,
.message,
.error,
.success {
  animation: icsSoftRise .32s ease both;
}
@keyframes icsSoftRise { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

.ics-upload-card {
  display:flex;
  align-items:center;
  gap:14px;
  padding:16px;
  border:1px dashed rgba(0,122,255,.45);
  border-radius:18px;
  background:rgba(0,122,255,.065);
  margin: 0 0 24px 0;
}
.ics-upload-card .upload-icon {
  width:44px;height:44px;border-radius:16px;display:grid;place-items:center;
  color:#fff;background:var(--sys-blue-gradient);box-shadow:0 8px 24px rgba(0,122,255,.24);
  flex:0 0 auto;
}
.ics-upload-card .upload-copy { min-width: 180px; flex:1; }
.ics-upload-card .upload-copy strong { display:block; color:var(--sys-text-main); }
.ics-upload-card .upload-copy span { display:block; color:var(--sys-text-muted); font-size:.84rem; margin-top:2px; }
.ics-upload-card input[type="file"] { flex: 1.4; min-width: 220px; }
@media (max-width: 760px) {
  .apple-tabs,.settings-tabs,.sub-tabs,.module-tabs,.page-tabs,.report-tabs,.tab-bar { width:100% !important; }
  .apple-tab,.sub-tab,.module-tab,.page-tab,.report-tab,.tab-link { flex:0 0 auto !important; }
  .ics-upload-card { flex-direction:column; align-items:stretch; }
  .ics-upload-card .upload-icon { align-self:flex-start; }
  .ics-upload-card input[type="file"] { width:100%; min-width:0; }
}


/* 2026-05 system-wide counter, backup/update, and mobile comfort refinement */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-wrap: anywhere; }
.content-wrapper, .main-content, .sys-card { min-width: 0; }

/* HR-style counters applied everywhere */
.kpi-grid, .dash-grid-top { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)) !important; gap: 20px !important; }
a.kpi-link-card, .kpi-link, .kpi-card-link { display:block; text-decoration:none !important; color:inherit !important; height:100%; }
.kpi-card, .mini-kpi-card {
  position: relative !important;
  overflow: hidden !important;
  border-radius: 22px !important;
  padding: 24px !important;
  background: linear-gradient(135deg, rgba(0,122,255,.10) 0%, rgba(255,255,255,.025) 55%, rgba(255,255,255,0) 100%), var(--sys-glass-bg) !important;
  border: 1px solid var(--sys-border) !important;
  border-top: 4px solid var(--sys-blue) !important;
  box-shadow: 0 18px 50px rgba(0,0,0,.16) !important;
  cursor: pointer !important;
  transition: transform .28s cubic-bezier(.2,.8,.2,1), box-shadow .28s ease, border-color .28s ease, background .28s ease !important;
  min-height: 132px;
}
.kpi-card::before, .mini-kpi-card::before { display:none !important; }
.kpi-card.green, .mini-kpi-card.green { border-top-color: var(--sys-success) !important; background: linear-gradient(135deg, rgba(52,199,89,.12) 0%, rgba(255,255,255,.025) 55%, rgba(255,255,255,0) 100%), var(--sys-glass-bg) !important; }
.kpi-card.red, .kpi-card.danger, .mini-kpi-card.red { border-top-color: var(--sys-danger) !important; background: linear-gradient(135deg, rgba(255,59,48,.12) 0%, rgba(255,255,255,.025) 55%, rgba(255,255,255,0) 100%), var(--sys-glass-bg) !important; }
.kpi-card.yellow, .kpi-card.orange, .kpi-card.warning, .mini-kpi-card.yellow { border-top-color: var(--sys-warning) !important; background: linear-gradient(135deg, rgba(255,149,0,.12) 0%, rgba(255,255,255,.025) 55%, rgba(255,255,255,0) 100%), var(--sys-glass-bg) !important; }
.kpi-card.purple, .mini-kpi-card.purple { border-top-color: var(--sys-purple) !important; background: linear-gradient(135deg, rgba(175,82,222,.12) 0%, rgba(255,255,255,.025) 55%, rgba(255,255,255,0) 100%), var(--sys-glass-bg) !important; }
.kpi-card[style*="--sys-success"], .kpi-card[style*="#34C759"] { border-top-color: var(--sys-success) !important; }
.kpi-card[style*="--sys-danger"], .kpi-card[style*="#FF3B30"] { border-top-color: var(--sys-danger) !important; }
.kpi-card[style*="--sys-warning"], .kpi-card[style*="#FF9500"] { border-top-color: var(--sys-warning) !important; }
.kpi-card[style*="--sys-purple"], .kpi-card[style*="#AF52DE"] { border-top-color: var(--sys-purple) !important; }
a:hover .kpi-card, .kpi-link:hover .kpi-card, .kpi-link-card:hover .kpi-card, .kpi-card:hover, .mini-kpi-card:hover {
  transform: translateY(-5px) !important;
  box-shadow: 0 24px 70px rgba(0,0,0,.22), 0 10px 28px rgba(0,122,255,.12) !important;
  border-color: rgba(255,255,255,.18) !important;
}
.kpi-title, .mini-kpi-card div:first-child {
  color: var(--sys-text-muted) !important;
  font-size: .78rem !important;
  text-transform: uppercase !important;
  letter-spacing: .08em !important;
  font-weight: 800 !important;
  margin-bottom: 12px !important;
}
.kpi-val, .hero-stat {
  font-size: clamp(1.85rem, 5vw, 2.65rem) !important;
  line-height: 1 !important;
  font-weight: 850 !important;
  color: var(--sys-text-main) !important;
  letter-spacing: -0.04em !important;
}
.kpi-foot { margin-top: 10px; font-size: .82rem; color: var(--sys-blue); font-weight: 700; }
.kpi-icon {
  position: absolute !important;
  right: -12px !important;
  bottom: -16px !important;
  font-size: clamp(4.4rem, 9vw, 6.4rem) !important;
  opacity: .065 !important;
  transition: .28s ease !important;
}
a:hover .kpi-icon, .kpi-card:hover .kpi-icon { opacity: .11 !important; transform: scale(1.08) rotate(-5deg) !important; }
[data-theme="light"] .kpi-card, [data-theme="light"] .mini-kpi-card { background: linear-gradient(135deg, rgba(0,122,255,.08), rgba(255,255,255,.72)), #fff !important; box-shadow: 0 18px 50px rgba(15,23,42,.08) !important; }

/* Dedicated Update/Backup controls */
.code-block { padding: 13px 14px; border: 1px solid var(--sys-border); border-radius: 16px; background: rgba(0,0,0,.22); color: var(--sys-text-main); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: .85rem; }
.update-dropzone .sys-btn { width: auto; }

/* Tablet/mobile layout fixes: readable without zooming */
@media (max-width: 1100px) {
  .main-content { padding: 18px !important; max-width: 100vw !important; }
  .sys-top-bar { align-items: stretch !important; }
  .sys-top-left, .sys-top-right, .sys-global-search { width: 100% !important; }
  .sys-top-right { display: grid !important; grid-template-columns: 1fr 1fr; gap: 10px !important; }
  .sys-global-search { display: block !important; grid-column: 1 / -1; }
  .sys-global-search .sys-input { font-size: 16px !important; }
  div[style*="grid-template-columns: repeat(4"],
  div[style*="grid-template-columns: repeat(3"],
  div[style*="grid-template-columns: 1fr 1fr 1fr"],
  div[style*="grid-template-columns: 2fr 1fr"],
  div[style*="grid-template-columns: 1fr 2fr"],
  div[style*="grid-template-columns: 1fr 2.5fr"],
  div[style*="grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr)"] { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 760px) {
  :root { --space-sm: 12px; --space-md: 16px; --space-lg: 20px; --element-height: 46px; }
  body { font-size: 15px; }
  .mobile-header { padding: 12px 14px !important; gap: 10px; }
  .mobile-header h3 { font-size: 1rem !important; line-height: 1.2; max-width: calc(100vw - 70px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main-content { padding: 12px !important; }
  .content-wrapper { width: 100%; overflow: visible; }
  .page-title { font-size: 1.35rem !important; line-height: 1.18; }
  .sys-top-right { grid-template-columns: 1fr !important; }
  .sys-pill { width: 100%; min-height: 40px; justify-content: center; text-align: center; }
  .sys-card, .auth-card { border-radius: 20px !important; padding: 16px !important; margin-bottom: 16px !important; }
  .kpi-grid, .dash-grid-top { grid-template-columns: 1fr !important; gap: 12px !important; margin-bottom: 16px !important; }
  .kpi-card, .mini-kpi-card { min-height: 118px; padding: 18px !important; }
  div[style*="display:grid"],
  div[style*="grid-template-columns: repeat(4"],
  div[style*="grid-template-columns: repeat(3"],
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr 1fr"],
  div[style*="grid-template-columns: 2fr 1fr"],
  div[style*="grid-template-columns: 1fr 2fr"],
  div[style*="grid-template-columns: 1fr 2.5fr"],
  div[style*="grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr)"] { grid-template-columns: 1fr !important; gap: 14px !important; }
  .flex-gap, .flex-between { gap: 10px !important; }
  input, select, textarea, .sys-input, .sys-select, .sys-textarea { font-size: 16px !important; max-width: 100%; }
  .sys-btn { min-height: 44px; white-space: normal; padding: 0 14px; }
  .sys-filter-line, .sys-bulk-line { padding: 12px !important; border-radius: 18px !important; }
  .sys-filter-actions, .bulk-actions { display: grid !important; grid-template-columns: 1fr !important; width: 100%; }
  .apple-tabs, .settings-tabs { width: 100% !important; border-radius: 18px !important; padding: 6px !important; }
  .apple-tab { flex: 0 0 auto; min-height: 40px; }
  .widget-header { padding: 14px 16px !important; align-items: flex-start; flex-direction: column; gap: 8px; }
  .widget-title { font-size: 1rem !important; }
  .task-item { align-items: flex-start !important; gap: 10px; padding: 13px !important; border-radius: 14px !important; }
  .task-item > div { min-width: 0; flex: 1; }
  .task-item span { display: inline-block; max-width: 100%; overflow-wrap: anywhere; }
  .note-card { border-radius: 18px !important; padding: 16px 42px 16px 16px !important; min-height: 64px; overflow-wrap: anywhere; }
  .note-delete { top: 12px !important; right: 14px !important; font-size: 1rem !important; }
  form[method="POST"][style*="display:flex"], form[style*="display:flex"] { flex-direction: column !important; align-items: stretch !important; }
  .sys-table-wrapper { border-radius: 18px !important; max-width: calc(100vw - 24px) !important; }
  table { min-width: 680px; }
  .ics-toast-stack { top: 12px; right: 12px; left: 12px; width: auto; }
  .ics-toast { grid-template-columns: 38px 1fr 28px; border-radius: 18px; padding: 12px; }
  .ics-toast-icon { width: 38px; height: 38px; border-radius: 14px; }
  .ics-modal-card { padding: 22px; border-radius: 24px; }
  .ics-modal-actions { display: grid; grid-template-columns: 1fr; }
  .ics-modal-actions .sys-btn { width: 100%; }
}
@media (max-width: 420px) {
  .main-content { padding: 10px !important; }
  .sys-card { padding: 14px !important; }
  .kpi-val, .hero-stat { font-size: 1.75rem !important; }
  .sys-pill { font-size: .82rem; }
}
