:root {
  --primary: #F554CD;
  --primary-hover: #b1338f;
  --accent: #F554CD;
  --sidebar-bg: #1f2937;
  --sidebar-active: #F554CD;
  --sidebar-text: #cbd5e1;
  --sidebar-active-text: #fff;
  --background: #f7f9fb;
  --card-bg: #fff;
  --table-header-bg: #fbe9f6;
  --table-row-alt: #f7ebf6;
  --input-border: #e9b5e5;
  --box-shadow: 0 4px 18px 0 rgba(0,0,0,0.07);
}

.layout {
  display: flex;
  flex: 1 0 auto;
  min-width: 0;
  min-height: 0;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

/* --- SIDEBAR --- */
.sidebar {
  width: 220px;  /* or 60px when collapsed */
  background: #1f2937;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: width 0.3s;
  /* REMOVE: position: fixed/absolute; */
  z-index: 15;
  overflow: hidden;
}

.sidebar .toggle-btn {
  position: absolute;
  top: 14px;
  left: 188px;
  width: 34px;
  height: 34px;
  background: var(--sidebar-bg);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px rgba(0,0,0,0.12);
  transition: left 0.3s;
  z-index: 20;
  border: none;
}

.sidebar.collapsed {
  width: 60px;
}

.sidebar.collapsed .toggle-btn {
  left: 14px;
}
.sidebar h2 {
  margin: 24px 0 32px 20px;
  font-size: 1.3rem;
  color: #fff;
  transition: opacity 0.2s;
}
.sidebar.collapsed h2 {
  opacity: 0;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.sidebar nav {
  width: 100%;
}
.sidebar nav a {
  display: block;
  padding: 14px 24px 14px 36px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 600;
  border-left: 4px solid transparent;
  border-radius: 0 16px 16px 0;
  margin-bottom: 8px;
  font-size: 1rem;
  transition: background 0.18s, border-color 0.18s, color 0.18s, padding 0.18s;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar nav a::before {
  content: attr(data-icon);
  display: inline-block;
  margin-right: 10px;
  font-size: 1.2em;
  vertical-align: middle;
}
.sidebar.collapsed nav a {
  padding-left: 18px;
  font-size: 0;
  border-radius: 12px;
}
.sidebar.collapsed nav a::before {
  margin-right: 0;
  font-size: 1.5em;
}
.sidebar.collapsed nav a span {
  display: none;
}
.sidebar nav a.active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-text);
  border-left-color: var(--accent);
}
.sidebar nav a:hover,
.sidebar nav a:focus {
  background-color: #33223a;
  color: #fff;
  border-left-color: var(--primary);
}

/* --- MAIN CONTENT --- */
.main-content {
  flex: 1;
  min-width: 0;
  /* REMOVE: margin-left, do NOT set margin-left */
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  background: var(--background, #f7f9fb);
}

.main-content.expanded {
  margin-left: 60px;
}

/* --- TOP BAR --- */
.top-bar {
  background: #fff;
  padding: 10px 20px;
  border-bottom: 1px solid #eee;
  font-size: 1em;
  z-index: 25;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  position: sticky;
  top: 0;
}
.top-bar a {
  margin-left: 20px;
  color: var(--primary);
  text-decoration: none;
  font-weight: bold;
}
.top-bar a:hover {
  text-decoration: underline;
}

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
  .sidebar, .sidebar.collapsed {
    width: 100vw;
    height: auto;
    flex-direction: row;
    padding-top: 0;
    position: relative;
  }
  .sidebar .toggle-btn, .sidebar.collapsed .toggle-btn {
    left: auto;
    right: 14px;
    top: 13px;
  }
  .main-content, .main-content.expanded {
    margin-left: 0;
    padding: 16px 2vw 0 2vw;
  }
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--background, #f7f9fb);
  color: #222;
}

/* Disabled buttons */
button:disabled,
.btn-disabled {
  background: #cfcfcf !important;
  color: #666 !important;
  cursor: not-allowed !important;
  border-color: #cfcfcf !important;
  box-shadow: none !important;
}

.main-content > .top-bar + * {
  margin-top: 24px;
}

.page-content {
  margin-top: 24px;
  flex: 1 0 auto;
}

.page-wrapper {
  flex: 1 0 auto;
  display: flex;
  flex-direction: row;
  min-height: 0;
}

.page-flex-root {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  flex: 1;
}

.top-bar a { margin-left: 20px; color: var(--primary); text-decoration: none; font-weight: bold;}
.top-bar a:hover { text-decoration: underline; }

.sidebar h2 {
  white-space: normal;
  word-break: break-word;
  margin: 0 0 2rem 0;
  padding: 0 1.2rem 0 1.2rem;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 1px;
  color: #fff;
  line-height: 1.2;
}

.sidebar nav {
  flex-grow: 1;
}
.sidebar a {
  display: block;
  padding: 14px 24px 14px 36px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 600;
  border-left: 4px solid transparent;
  border-radius: 0 16px 16px 0;
  margin-bottom: 8px;
  font-size: 1rem;
  transition: background-color 0.18s, border-color 0.18s, color 0.18s;
}
.sidebar a.active {
  background-color: var(--sidebar-active);
  color: var(--sidebar-active-text);
  border-left-color: var(--accent);
}
.sidebar a:hover,
.sidebar a:focus {
  background-color: #33223a;
  color: #fff;
  border-left-color: var(--primary);
}

/* Toggle button styles */
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed + .toggle-btn { left: 60px; }
.container.expanded { margin-left: 60px; }

@media (max-width: 1024px) {
  .container { padding: 16px 2vw 16px 2vw; max-width: 99vw; }
}

@media (max-width: 700px) {
  .sidebar { width: 100vw; height: auto; flex-direction: row; padding-top: 0;}
  .sidebar.collapsed { width: 100vw; }
  .sidebar a, .sidebar h2 { text-align: center; padding: 12px 6px;}
  .toggle-btn { left: auto; right: 20px; top: 13px; }
  .container, .container.expanded { margin-left: 0; padding: 5vw 1vw;}
}

@media (max-width: 900px) {
  .container {
    width: 99vw;
    margin: 24px 0 0 0;
    padding: 12px 2vw 12px 2vw;
  }
}

.export-controls {
  min-width: 230px;
  margin-left: 18px;
}

@media (max-width: 1200px) {
  .export-controls {
    margin-left: 0;
    min-width: 0;
    width: 100%;
    text-align: left;
    margin-top: 10px;
  }
  .filter-bar {
    width: 100%;
    min-width: 0;
    margin-bottom: 8px;
  }
  /* Make parent flex column so export controls move below filter-bar */
  [style*="display: flex;"][style*="flex-wrap: wrap;"] {
    flex-direction: column !important;
    align-items: stretch !important;
  }
}


/* Filter bar & controls */
.filter-bar {
  background: #f4f6fa;
  padding: 18px 18px 12px 18px;
  border-radius: 12px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  box-shadow: 0 2px 8px rgba(30,40,60,0.03);
}
.filter-bar label {
  margin-right: 8px;
  font-weight: 600;
}
.filter-bar input[type="text"], .filter-bar input[type="date"], .filter-bar select {
  min-width: 130px;
  font-size: 14px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  padding: 7px 10px;
  background: #f8fafc;
  margin-bottom: 3px;
  margin-right: 8px;
  transition: border 0.15s;
}
.filter-bar input[type="text"]:focus, .filter-bar input[type="date"]:focus, .filter-bar select:focus {
  border: 1.5px solid var(--primary);
  background: #fff;
  outline: none;
}
.filter-bar button, .filter-bar .btn {
  font-size: 14px;
  border-radius: 6px;
  border: none;
  padding: 8px 20px;
  background: var(--primary);
  color: #fff;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s;
  box-shadow: 0 2px 8px 0 rgba(0,0,0,0.05);
}
.filter-bar button:hover, .filter-bar .btn:hover {
  background: var(--primary-hover);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}
table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 14px;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 10px 0 rgba(0,0,0,0.03);
}
th, td {
  padding: 10px 8px;
  border-bottom: 1px solid #e3e8ee;
  max-width: 180px;
  word-break: break-word;
}
th {
  background: var(--table-header-bg);
  font-weight: 700;
  color: var(--primary);
  text-align: left;
}
tr:nth-child(even) { background: var(--table-row-alt); }
tr:hover { background-color: #fbe3f6; }
th:last-child, td:last-child { border-right: none; }
th:first-child, td:first-child { border-left: none; }

.pagination { margin: 18px 0; }

button, .btn {
  font-size: 14px;
  border-radius: 6px;
  padding: 7px 14px;
  border: none;
  margin: 0 2px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s;
  box-shadow: 0 2px 6px 0 rgba(0,0,0,0.07);
}
button:hover, .btn:hover {
  background: var(--primary-hover);
}

.status { font-size: 13px; color: #099206; }
.error { font-size: 13px; color: #d32f2f; }
.spinner {
  border: 2px solid #f3f3f3;
  border-top: 2px solid #F554CD;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
  margin-right: 2px;
}
@keyframes spin { 0% { transform: rotate(0deg);} 100% { transform: rotate(360deg);} }


footer {
  text-align: center;
  color: #888;
  font-size: 13px;
  margin: 0;
  padding: 12px 0;
  background: transparent;
  flex-shrink: 0;
}

/* Extra scroll bar style */
::-webkit-scrollbar-thumb { background: #e3e8ee; border-radius: 8px; }
::-webkit-scrollbar-track { background: #f7f9fb;}
