/* ==========================================================================
   Design Tokens
   ========================================================================== */

:root {
  /* Surfaces */
  --app-sidebar-bg: white;
  --app-content-bg: #F5F4F2;
  --app-chrome-bg: #F5F4F2;
  --app-chrome-border: rgba(70, 69, 69, 0.1);

  /* Accent / interactive cards */
  --app-accent-bg: #F6E3E4;
  --app-card-bg: white;
  --app-card-border: #EBE9E5;

  /* Primary button */
  --app-btn-primary: #4B3030;
  --app-btn-primary-hover: #643335;
  --app-on-btn-primary: white;

  /* Text hierarchy */
  --app-text: black;
  --app-text-secondary: #464545;
  --app-text-meta: #464545;
  --app-icon-muted: #999;
  --app-link: #2563EB;

  /* Focus & active states */
  --app-focus-ring: #84CAFF;
  --app-item-active-bg: #F6E3E4;

  /* Status colors */
  --status-open-bg: #fef3c7;
  --status-open-text: #92400e;
  --status-progress-bg: #dbeafe;
  --status-progress-text: #1e40af;
  --status-resolved-bg: #d1fae5;
  --status-resolved-text: #065f46;

  /* Success */
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --success-text: #166534;

  /* Error */
  --error-text: #dc2626;
}


/* ==========================================================================
   Reset & Base
   ========================================================================== */

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

body {
  font-family: system-ui, -apple-system, sans-serif;
  letter-spacing: 0.025rem;
  color: var(--app-text);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--app-content-bg);
}

a {
  color: var(--app-link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.3;
}


/* ==========================================================================
   Scrollbars
   ========================================================================== */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}


/* ==========================================================================
   Focus & Accessibility
   ========================================================================== */

*:focus-visible {
  outline: 2px solid var(--app-focus-ring);
  outline-offset: 2px;
}

button:focus:not(:focus-visible) {
  outline: none;
}


/* ==========================================================================
   AppShell Layout
   ========================================================================== */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 48px;
  background: white;
  border-bottom: 1px solid var(--app-chrome-border);
  flex-shrink: 0;
}

.app-header__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header__title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05rem;
  text-transform: uppercase;
  color: var(--app-text);
  text-decoration: none;
}
.app-header__title:hover {
  text-decoration: none;
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.app-sidebar {
  width: 290px;
  background: var(--app-sidebar-bg);
  border-right: 1px solid var(--app-chrome-border);
  overflow-y: auto;
  flex-shrink: 0;
  display: none;
}

.app-sidebar__section-label {
  padding: 16px 16px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08rem;
  color: var(--app-icon-muted);
}

/* Main content */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--app-content-bg);
}

.app-main__inner {
  flex: 1;
  padding: 24px 16px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.3);
}
.sidebar-overlay.active {
  display: block;
}

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--app-text-secondary);
}
.sidebar-toggle:hover {
  color: var(--app-text);
}

@media (min-width: 768px) {
  .app-sidebar {
    display: block;
    position: static;
  }
  .sidebar-toggle {
    display: none;
  }
  .sidebar-overlay {
    display: none !important;
  }
}

/* Sidebar mobile open state */
.app-sidebar.open {
  display: block;
  position: fixed;
  top: 48px;
  left: 0;
  bottom: 0;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}


/* ==========================================================================
   Navigation Items
   ========================================================================== */

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--app-text-secondary);
  text-decoration: none;
  transition: background 0.15s ease;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  background: rgba(0, 0, 0, 0.03);
  text-decoration: none;
}
.nav-item.active {
  background: var(--app-item-active-bg);
  font-weight: 600;
}

.nav-item__icon {
  width: 16px;
  height: 16px;
  color: var(--app-icon-muted);
  flex-shrink: 0;
}
.nav-item.active .nav-item__icon {
  color: var(--app-text);
}

.nav-item__badge {
  margin-left: auto;
  background: var(--app-accent-bg);
  color: var(--app-text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 9999px;
}


/* ==========================================================================
   Buttons
   ========================================================================== */

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--app-btn-primary);
  color: var(--app-on-btn-primary);
  padding: 9px 16px;
  border-radius: 9999px;
  border: none;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}
.btn-primary:hover {
  background: var(--app-btn-primary-hover);
  text-decoration: none;
  color: var(--app-on-btn-primary);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: white;
  color: var(--app-text-secondary);
  padding: 9px 16px;
  border-radius: 9999px;
  border: 1px solid var(--app-card-border);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}
.btn-secondary:hover {
  background: var(--app-content-bg);
  text-decoration: none;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 4px;
  border: none;
  background: none;
  color: var(--app-icon-muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.btn-icon:hover {
  color: var(--app-text);
  background: rgba(0, 0, 0, 0.05);
}


/* ==========================================================================
   Cards & Containers
   ========================================================================== */

.card {
  background: var(--app-card-bg);
  border: 1px solid var(--app-card-border);
  border-radius: 0;
  padding: 12px 16px;
}

.section-card {
  background: var(--app-card-bg);
  border: 1px solid var(--app-card-border);
  border-radius: 0;
  margin-bottom: 2px;
}

.section-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--app-card-border);
}

.section-header__info h2 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}
.section-header__info p {
  font-size: 12px;
  color: var(--app-text-meta);
  margin: 0;
}

.section-header__count {
  font-size: 11px;
  font-weight: 600;
  color: var(--app-text-meta);
  background: var(--app-content-bg);
  padding: 2px 8px;
}


/* ==========================================================================
   Issue Items
   ========================================================================== */

.issue-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--app-card-border);
  transition: background 0.15s ease;
}
.issue-item:last-child {
  border-bottom: none;
}
.issue-item:hover {
  background: rgba(0, 0, 0, 0.01);
}

.issue-item__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.issue-item__title {
  font-size: 14px;
  font-weight: 600;
}

.issue-item__actions {
  opacity: 0;
  transition: opacity 0.15s;
  display: flex;
  gap: 4px;
}
.issue-item:hover .issue-item__actions {
  opacity: 1;
}

.issue-item__data {
  margin-top: 6px;
  font-size: 12px;
  color: var(--app-text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.issue-item__data strong {
  color: var(--app-text);
}

.issue-item__meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--app-icon-muted);
  display: flex;
  gap: 12px;
  align-items: center;
}

.no-issues {
  padding: 16px;
  color: var(--app-icon-muted);
  font-size: 13px;
}

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--app-icon-muted);
}
.empty-state__icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  color: var(--app-card-border);
}
.empty-state__text {
  font-size: 14px;
}


/* ==========================================================================
   Status Badges
   ========================================================================== */

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03rem;
}

.status-badge--open {
  background: var(--status-open-bg);
  color: var(--status-open-text);
}
.status-badge--in_progress {
  background: var(--status-progress-bg);
  color: var(--status-progress-text);
}
.status-badge--resolved {
  background: var(--status-resolved-bg);
  color: var(--status-resolved-text);
}


/* ==========================================================================
   Success & Error Messages
   ========================================================================== */

.alert-success {
  padding: 12px 16px;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: 0;
  color: var(--success-text);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}


/* ==========================================================================
   Forms
   ========================================================================== */

.form-card {
  background: var(--app-card-bg);
  border: 1px solid var(--app-card-border);
  border-radius: 0;
  padding: 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04rem;
  margin-bottom: 6px;
  color: var(--app-text-secondary);
}

.form-group .help-text {
  font-size: 12px;
  color: var(--app-icon-muted);
  margin-top: 4px;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--app-card-border);
  border-radius: 0;
  font-size: 14px;
  font-family: inherit;
  color: var(--app-text);
  background: white;
  transition: border-color 0.15s ease;
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--app-focus-ring);
  box-shadow: 0 0 0 2px var(--app-focus-ring);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.form-group .errorlist {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  color: var(--error-text);
  font-size: 12px;
}

.form-group ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.form-group ul li {
  margin-bottom: 4px;
}
.form-group ul li label {
  text-transform: none;
  font-weight: 400;
  font-size: 14px;
  display: inline;
  margin-left: 6px;
}

.section-fields-divider {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06rem;
  color: var(--app-icon-muted);
  margin: 20px 0 12px;
  border-top: 1px solid var(--app-card-border);
  padding-top: 16px;
}

.form-actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  align-items: center;
}


/* ==========================================================================
   Page Header
   ========================================================================== */

.page-header {
  margin-bottom: 24px;
}

.page-header__title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.page-header__subtitle {
  font-size: 13px;
  color: var(--app-text-meta);
}

.page-header__actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}


/* ==========================================================================
   Icon Utilities
   ========================================================================== */

.icon {
  display: inline-block;
  vertical-align: middle;
}
.icon--sm { width: 14px; height: 14px; }
.icon--md { width: 18px; height: 18px; }
.icon--lg { width: 24px; height: 24px; }


/* ==========================================================================
   Back Link
   ========================================================================== */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04rem;
  color: var(--app-text-secondary);
  text-decoration: none;
  margin-bottom: 20px;
}
.back-link:hover {
  color: var(--app-text);
  text-decoration: none;
}


/* ==========================================================================
   Full-width Layout (no sidebar)
   ========================================================================== */

.app-body--full .app-sidebar {
  display: none !important;
}
.app-body--full .sidebar-toggle {
  display: none !important;
}
.app-body--full .app-main__inner {
  max-width: 1100px;
}


/* ==========================================================================
   Status Page: Service Grid
   ========================================================================== */

.service-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 600px) {
  .service-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px) {
  .service-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}


/* ==========================================================================
   Status Page: Service Cards
   ========================================================================== */

.service-card {
  background: var(--app-card-bg);
  border: 1px solid var(--app-card-border);
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

.service-card__header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--app-card-border);
}

.service-card__body {
  padding: 16px;
  border-bottom: 1px solid var(--app-card-border);
}

.service-card__name {
  font-size: 15px;
  font-weight: 600;
}

.service-card__desc {
  font-size: 12px;
  color: var(--app-text-meta);
  margin-top: 4px;
  line-height: 1.4;
}

/* Service status indicator */
.service-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03rem;
  white-space: nowrap;
  padding: 4px 12px;
}

.service-status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.service-status--operational { color: #065f46; }
.service-status--operational .service-status__dot { background: #10b981; }

.service-status--degraded { color: #92400e; }
.service-status--degraded .service-status__dot { background: #f59e0b; }

.service-status--outage { color: #991b1b; }
.service-status--outage .service-status__dot { background: #ef4444; }

.service-status--maintenance { color: #1e40af; }
.service-status--maintenance .service-status__dot { background: #3b82f6; }


/* ==========================================================================
   Status Page: Bulletins
   ========================================================================== */

.bulletin {
  border-bottom: 1px solid var(--app-card-border);
}
.bulletin:last-child {
  border-bottom: none;
}

.bulletin__toggle {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  transition: background 0.15s ease;
  position: relative;
}
.bulletin__toggle:hover {
  background: rgba(0, 0, 0, 0.015);
}

.bulletin__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.bulletin__title {
  font-size: 14px;
  font-weight: 600;
}

.bulletin__date {
  font-size: 12px;
  color: var(--app-icon-muted);
  white-space: nowrap;
}

.bulletin__preview {
  font-size: 13px;
  color: var(--app-text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: left;
}

.bulletin__chevron {
  position: absolute;
  right: 16px;
  top: 16px;
  color: var(--app-icon-muted);
  transition: transform 0.2s ease;
}

.bulletin__content {
  display: none;
  padding: 0 16px 16px;
}

.bulletin__block {
  font-size: 14px;
  line-height: 1.6;
  color: var(--app-text-secondary);
  margin-bottom: 12px;
}
.bulletin__block p {
  margin: 0 0 8px;
}
.bulletin__block p:last-child {
  margin-bottom: 0;
}

.bulletin__update {
  padding: 10px 14px;
  border-left: 3px solid var(--app-card-border);
  margin-bottom: 12px;
}
.bulletin__update:last-child {
  margin-bottom: 0;
}

.bulletin__timestamp {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--app-text);
  margin-bottom: 4px;
}

.bulletin__update-text {
  font-size: 13px;
  color: var(--app-text-secondary);
  line-height: 1.5;
}
.bulletin__update-text p {
  margin: 0 0 4px;
}
.bulletin__update-text p:last-child {
  margin-bottom: 0;
}

/* Expanded state */
.bulletin.expanded .bulletin__preview {
  display: none;
}
.bulletin.expanded .bulletin__content {
  display: block;
}
.bulletin.expanded .bulletin__chevron {
  transform: rotate(180deg);
}


/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 767px) {
  .app-main__inner {
    padding: 16px 12px;
    padding-bottom: 80px;
  }

  .issue-item__actions {
    opacity: 1;
  }

  .form-card {
    padding: 16px;
  }

  .page-header__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-primary,
  .btn-secondary {
    justify-content: center;
  }
}
