/* Tabys Platform CEO — iOS-style (simple system colors + glass) */

:root {
  color-scheme: light dark;
  --ios-bg: #f2f2f7;
  --ios-group: #ffffff;
  --ios-text: #000000;
  --ios-text2: #3c3c43;
  --ios-label: #8e8e93;
  --ios-separator: rgba(60, 60, 67, 0.12);
  --ios-blue: #007aff;
  --ios-green: #34c759;
  --ios-red: #ff3b30;
  --ios-orange: #ff9500;
  --ios-fill: rgba(120, 120, 128, 0.12);
  --ios-nav-bg: rgba(242, 242, 247, 0.78);
  --ios-tab-bg: rgba(248, 248, 248, 0.88);
  --ios-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
  --ios-radius: 14px;
  --ios-radius-lg: 22px;
  --ios-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ios-bg: #000000;
    --ios-group: #1c1c1e;
    --ios-text: #ffffff;
    --ios-text2: #ebebf5;
    --ios-label: #8e8e93;
    --ios-separator: rgba(84, 84, 88, 0.65);
    --ios-fill: rgba(120, 120, 128, 0.24);
    --ios-nav-bg: rgba(28, 28, 30, 0.82);
    --ios-tab-bg: rgba(28, 28, 30, 0.92);
    --ios-shadow: 0 2px 24px rgba(0, 0, 0, 0.35);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body.ios-platform {
  margin: 0;
  min-height: 100svh;
  font-family: var(--ios-font);
  font-size: 17px;
  line-height: 1.35;
  background: var(--ios-bg);
  color: var(--ios-text);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--ios-blue);
  text-decoration: none;
}

.ios-app {
  max-width: 680px;
  margin: 0 auto;
  padding-bottom: calc(72px + var(--safe-bottom));
}

.ios-app.no-tabbar {
  padding-bottom: calc(24px + var(--safe-bottom));
}

a.ios-row-link {
  text-decoration: none;
  color: inherit;
  align-items: center;
  transition: background 0.15s;
}

a.ios-row-link:active {
  background: var(--ios-fill);
}

/* —— Nav —— */
.ios-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: var(--ios-nav-bg);
  border-bottom: 0.5px solid var(--ios-separator);
}

.ios-nav-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.ios-nav-btn {
  appearance: none;
  border: none;
  background: var(--ios-fill);
  color: var(--ios-blue);
  font: 600 15px/1 var(--ios-font);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.15s;
}

.ios-nav-btn:active {
  transform: scale(0.94);
  opacity: 0.85;
}

.ios-nav-btn.ghost {
  background: transparent;
  color: var(--ios-blue);
  padding: 7px 4px;
}

/* —— Hero / large title —— */
.ios-hero {
  padding: 8px 20px 4px;
}

.ios-large-title {
  font-size: clamp(28px, 7vw, 34px);
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0 0 4px;
  line-height: 1.1;
}

.ios-subtitle {
  margin: 0;
  font-size: 15px;
  color: var(--ios-label);
}

/* —— Stats scroll —— */
.ios-stats {
  display: flex;
  gap: 10px;
  padding: 12px 20px 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.ios-stats::-webkit-scrollbar {
  display: none;
}

.ios-stat {
  flex: 0 0 auto;
  scroll-snap-align: start;
  min-width: 88px;
  padding: 14px 16px;
  background: var(--ios-group);
  border-radius: var(--ios-radius);
  box-shadow: var(--ios-shadow);
}

.ios-stat strong {
  display: block;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.ios-stat span {
  font-size: 12px;
  color: var(--ios-label);
  margin-top: 2px;
  display: block;
}

/* —— Grouped content —— */
.ios-section-label {
  font-size: 13px;
  font-weight: 400;
  color: var(--ios-label);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 20px 20px 8px;
}

.ios-inset {
  margin: 0 16px;
  background: var(--ios-group);
  border-radius: var(--ios-radius);
  overflow: hidden;
  box-shadow: var(--ios-shadow);
}

.ios-inset + .ios-inset {
  margin-top: 12px;
}

.ios-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--ios-separator);
}

.ios-inset.ios-tenant-list {
  margin-bottom: 24px;
}

.ios-tenant-row {
  opacity: 1 !important;
  visibility: visible !important;
  min-height: 48px;
}

.ios-tenant-row .ios-row-title {
  color: var(--ios-text);
}

.ios-row-main {
  flex: 1;
  min-width: 0;
}

.ios-row-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 2px;
  letter-spacing: -0.02em;
}

.ios-row-meta {
  font-size: 13px;
  color: var(--ios-label);
  margin: 0;
  line-height: 1.4;
}

.ios-chevron {
  color: var(--ios-label);
  font-size: 20px;
  line-height: 1;
  margin-top: 2px;
  opacity: 0.45;
}

/* —— Search bar —— */
.ios-search-wrap {
  padding: 8px 16px 4px;
}

.ios-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ios-fill);
  border-radius: 12px;
  padding: 10px 12px;
}

.ios-search input,
.ios-search select {
  flex: 1;
  border: none;
  background: transparent;
  font: 17px/1.2 var(--ios-font);
  color: var(--ios-text);
  outline: none;
  min-width: 0;
}

.ios-search select {
  flex: 0 0 auto;
  max-width: 42%;
}

/* —— Pills / badges —— */
.ios-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin: 2px 4px 2px 0;
}

.ios-pill.ok {
  background: rgba(52, 199, 89, 0.18);
  color: var(--ios-green);
}

.ios-pill.bad {
  background: rgba(255, 59, 48, 0.15);
  color: var(--ios-red);
}

.ios-pill.warn {
  background: rgba(255, 149, 0, 0.18);
  color: var(--ios-orange);
}

/* —— Buttons —— */
.ios-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.ios-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font: 600 15px/1 var(--ios-font);
  padding: 10px 14px;
  border-radius: 12px;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.15s;
}

.ios-btn:active {
  transform: scale(0.96);
  filter: brightness(0.92);
}

.ios-btn.blue {
  background: var(--ios-blue);
  color: #fff;
}

.ios-btn.green {
  background: var(--ios-green);
  color: #fff;
}

.ios-btn.red {
  background: var(--ios-red);
  color: #fff;
}

.ios-btn.gray {
  background: var(--ios-fill);
  color: var(--ios-text);
}

.ios-btn.sm {
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 10px;
}

form.ios-inline {
  display: inline;
}

/* —— Tab bar —— */
.ios-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  justify-content: space-around;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  background: var(--ios-tab-bg);
  border-top: 0.5px solid var(--ios-separator);
}

.ios-tab {
  flex: 1;
  text-align: center;
  font-size: 10px;
  font-weight: 500;
  color: var(--ios-label);
  padding: 4px 8px;
  border-radius: 10px;
  transition: color 0.2s, background 0.2s;
}

.ios-tab svg {
  display: block;
  margin: 0 auto 4px;
  width: 26px;
  height: 26px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
}

.ios-tab.active {
  color: var(--ios-blue);
}

.ios-tab:active {
  background: var(--ios-fill);
}

/* —— Messages —— */
.ios-toast {
  margin: 12px 16px;
  padding: 12px 14px;
  border-radius: var(--ios-radius);
  font-size: 15px;
  animation: ios-slide-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ios-toast.success {
  background: rgba(52, 199, 89, 0.15);
  color: var(--ios-green);
}

.ios-toast.error {
  background: rgba(255, 59, 48, 0.12);
  color: var(--ios-red);
}

.ios-toast.warning {
  background: rgba(255, 149, 0, 0.15);
  color: var(--ios-orange);
}

.ios-toast.info {
  background: rgba(0, 122, 255, 0.12);
  color: var(--ios-blue);
}

@keyframes ios-slide-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* —— Forms —— */
.ios-field {
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--ios-separator);
}

.ios-field:last-child {
  border-bottom: none;
}

.ios-field label {
  display: block;
  font-size: 13px;
  color: var(--ios-label);
  margin-bottom: 6px;
}

.ios-field input[type="text"],
.ios-field input[type="number"],
.ios-field input[type="email"],
.ios-field input[type="password"],
.ios-field textarea {
  width: 100%;
  border: none;
  background: transparent;
  font: 17px/1.3 var(--ios-font);
  color: var(--ios-text);
  outline: none;
  resize: vertical;
}

.ios-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--ios-separator);
  font-size: 17px;
}

.ios-toggle-row:last-child {
  border-bottom: none;
}

.ios-toggle-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--ios-green);
}

.ios-footnote {
  margin: 16px 20px 24px;
  font-size: 13px;
  color: var(--ios-label);
  line-height: 1.45;
}

/* —— Login sheet —— */
body.ios-login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  min-height: 100svh;
}

.ios-login-sheet {
  width: 100%;
  max-width: 400px;
  background: var(--ios-group);
  border-radius: var(--ios-radius-lg);
  box-shadow: var(--ios-shadow);
  overflow: hidden;
}

.ios-login-hero {
  padding: 28px 24px 8px;
  text-align: center;
}

.ios-login-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: linear-gradient(145deg, #007aff, #5856d6);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 122, 255, 0.35);
}

@media (min-width: 720px) {
  .ios-app {
    max-width: 720px;
  }

  .ios-tabbar {
    max-width: 720px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 20px 20px 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ios-btn,
  .ios-nav-btn,
  .ios-tab {
    transition: none;
  }
}
