/* Professional color scheme for production planning software */
:root {
  --bg: #f8fafc;
  --bg-secondary: #f1f5f9;
  --card: #ffffff;
  --muted: #64748b;
  --fg: #0f172a;
  --fg-secondary: #334155;
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --primary-light: #e0f2fe;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --line: #e2e8f0;
  --line-dark: #cbd5e1;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px / 1.6 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden {
  display: none !important;
}

/* Modern layout with better spacing */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  background: var(--bg);
}

/* Professional sidebar design */
aside.sidebar {
  background: var(--card);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.brandbox {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 20px 16px;
  border-bottom: 1px solid var(--line);
}

/* Elegant brand logo without gradient */
.brandlogo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--primary);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.5px;
  box-shadow: var(--shadow);
}

.brandtxt {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brandtxt .t {
  font-weight: 600;
  font-size: 15px;
  color: var(--fg);
  letter-spacing: -0.3px;
}

.brandtxt .s {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* Clean menu design without emojis */
.menu {
  padding: 12px;
  flex: 1;
  overflow-y: auto;
}

.menu button,
.menu .linkbtn {
  width: 100%;
  text-align: left;
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 2px 0;
  background: transparent;
  border: none;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--fg-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  position: relative;
}

.menu button::before {
  content: "";
  width: 3px;
  height: 0;
  background: var(--primary);
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 0 2px 2px 0;
  transition: height 0.15s ease;
}

.menu button:hover {
  background: var(--bg-secondary);
  color: var(--fg);
}

.menu button.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.menu button.active::before {
  height: 20px;
}

.menu button.danger {
  color: var(--danger);
  margin-top: auto;
}

.menu button.danger:hover {
  background: var(--danger-light);
}

.menu .linkbtn {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

.menu .linkbtn:hover {
  background: var(--bg-secondary);
  color: var(--fg-secondary);
}

/* Professional top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

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

.logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: white;
  font-size: 16px;
  box-shadow: var(--shadow);
}

.titles h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.4px;
}

.titles p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.userbox {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-secondary);
}

/* Modern button styles */
button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 500;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  font-family: inherit;
}

button:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line-dark);
  color: var(--fg-secondary);
  box-shadow: none;
}

button.ghost:hover {
  background: var(--bg-secondary);
  border-color: var(--line-dark);
  color: var(--fg);
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: #dc2626;
}

/* Better main content area */
main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0;
  width: 100%;
}

.section {
  padding: 24px;
}

/* Elegant card design */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  width: 100%;
}

.card h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--fg);
  margin: 0 0 4px 0;
  letter-spacing: -0.4px;
}

.card h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
  margin: 0 0 12px 0;
  letter-spacing: -0.3px;
}

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

.row {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 16px;
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.grid3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

/* Professional form inputs */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--fg-secondary);
  font-size: 13px;
  font-weight: 500;
}

input,
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--line-dark);
  color: var(--fg);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

input::placeholder {
  color: var(--muted);
}

/* Modern table design */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table th {
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--line);
  padding: 12px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: var(--fg-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.table th:first-child {
  border-top-left-radius: var(--radius);
}

.table th:last-child {
  border-top-right-radius: var(--radius);
}

.table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  font-size: 14px;
  color: var(--fg);
}

.table tr:hover {
  background: var(--bg-secondary);
}

.table tr:last-child td:first-child {
  border-bottom-left-radius: var(--radius);
}

.table tr:last-child td:last-child {
  border-bottom-right-radius: var(--radius);
}

/* Professional dialog styling */
dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  min-width: 500px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  /* Center dialog on screen */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
}

/* Added form styling inside dialogs */
dialog form {
  display: flex;
  flex-direction: column;
}

dialog h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--fg);
  margin: 0;
  letter-spacing: -0.4px;
}

dialog label {
  margin-bottom: 0;
}

dialog input,
dialog select,
dialog textarea {
  margin-top: 4px;
}

/* Better Gantt chart container */
.ganttbox {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.muted {
  color: var(--muted);
}

/* Professional alert styling */
.alert {
  margin-top: 12px;
  padding: 12px 16px;
  border: 1px solid var(--warning);
  background: var(--warning-light);
  border-radius: var(--radius);
  color: #92400e;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Modern hero section */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  min-height: 240px;
  border-radius: var(--radius-lg);
  border: none;
  display: flex;
  align-items: end;
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("img/background.jpg") no-repeat center / cover;
  opacity: 0.15;
  mix-blend-mode: overlay;
}

.hero > div {
  position: relative;
  z-index: 1;
}

.hero h2 {
  color: white;
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px 0;
  letter-spacing: -0.6px;
}

.hero p {
  color: rgba(255, 255, 255, 0.9);
  font-size: 16px;
  margin: 0;
}

.hero .row {
  margin-top: 16px;
}

.hero .linkbtn {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 10px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.15s ease;
  display: inline-block;
}

.hero .linkbtn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}

.loginwall {
  display: grid;
  place-items: center;
  height: 50vh;
  color: var(--muted);
  font-size: 18px;
  font-weight: 500;
}

.small {
  font-size: 13px;
  padding: 6px 10px;
}

/* Switch/checkbox styling */
.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.switch input[type="checkbox"] {
  width: 40px;
  height: 22px;
  appearance: none;
  background: var(--line-dark);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
  border: none;
  padding: 0;
}

.switch input[type="checkbox"]::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: transform 0.2s ease;
  box-shadow: var(--shadow);
}

.switch input[type="checkbox"]:checked {
  background: var(--primary);
}

.switch input[type="checkbox"]:checked::before {
  transform: translateX(18px);
}

.switch input[type="checkbox"]:focus {
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Range input styling */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  border: none;
}

input[type="range"]::-webkit-slider-track {
  background: var(--line-dark);
  height: 6px;
  border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  background: var(--primary);
  height: 18px;
  width: 18px;
  border-radius: 50%;
  margin-top: -6px;
  box-shadow: var(--shadow);
}

input[type="range"]::-moz-range-track {
  background: var(--line-dark);
  height: 6px;
  border-radius: 3px;
}

input[type="range"]::-moz-range-thumb {
  background: var(--primary);
  height: 18px;
  width: 18px;
  border-radius: 50%;
  border: none;
  box-shadow: var(--shadow);
}

input[type="range"]:focus {
  outline: none;
}

input[type="range"]:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* File input styling */
.filelabel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  color: var(--fg-secondary);
  transition: all 0.15s ease;
}

.filelabel:hover {
  background: var(--bg);
  border-color: var(--primary);
  color: var(--fg);
}

.filelabel input[type="file"] {
  display: none;
}

/* Ordered list styling */
ol {
  padding-left: 20px;
  margin: 12px 0;
}

ol li {
  padding: 8px 0;
  color: var(--fg-secondary);
  line-height: 1.6;
}

/* Horizontal rule */
hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

/* KPIs display */
#kpis {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 16px;
}

#kpis > div {
  flex: 1;
  min-width: 200px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

/* Responsive design */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }

  aside.sidebar {
    position: relative;
    height: auto;
  }

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

@media (max-width: 640px) {
  .section {
    padding: 16px;
  }

  .card {
    padding: 16px;
  }

  .grid2,
  .grid3 {
    grid-template-columns: 1fr;
  }

  dialog {
    min-width: auto;
    width: 90vw;
  }
}

/* Spreadsheet-like table styles for MS Project look */
.spreadsheet-container {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.spreadsheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.spreadsheet-table thead {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-secondary);
}

.spreadsheet-table th {
  background: var(--bg-secondary);
  border-right: 1px solid var(--line);
  border-bottom: 2px solid var(--line-dark);
  padding: 10px 8px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--fg-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  position: relative;
}

.spreadsheet-table th:last-child {
  border-right: none;
}

.spreadsheet-table tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background 0.1s ease;
}

.spreadsheet-table tbody tr:hover {
  background: var(--bg-secondary);
}

.spreadsheet-table td {
  border-right: 1px solid var(--line);
  padding: 8px;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

.spreadsheet-table td:last-child {
  border-right: none;
}

/* Editable cells styling */
.editable-cell {
  cursor: pointer;
  position: relative;
}

.editable-cell:hover {
  background: var(--primary-light);
  outline: 1px solid var(--primary);
}

.editable-cell.editing {
  padding: 0;
  background: white;
  outline: 2px solid var(--primary);
}

.editable-cell .cell-content {
  display: block;
  width: 100%;
  padding: 8px;
}

.editable-cell input,
.editable-cell select {
  width: 100%;
  border: none;
  padding: 8px;
  margin: 0;
  font-size: 13px;
  background: white;
}

.editable-cell input:focus,
.editable-cell select:focus {
  outline: none;
  box-shadow: none;
}

/* Empty row for quick add */
.empty-row {
  background: var(--bg);
  transition: background 0.2s ease;
}

.empty-row:hover {
  background: var(--primary-light);
  cursor: pointer;
}

/* Actions cell */
.actions-cell {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.actions-cell button {
  padding: 4px 8px;
  font-size: 12px;
  min-width: auto;
  box-shadow: none;
}

/* Badge styling for status indicators */
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-secondary);
  color: var(--fg-secondary);
}

/* Added column resize handle styling */
.col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  user-select: none;
  z-index: 10;
}

.col-resize-handle:hover {
  background: var(--primary);
  opacity: 0.3;
}

.col-resize-handle:active {
  background: var(--primary);
  opacity: 0.5;
}

.col-header-content {
  display: inline-block;
  pointer-events: none;
}

/* Added collapse/expand button styling for task hierarchy */
.collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 4px;
  font-size: 14px;
  color: var(--fg-secondary);
  transition: color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-right: 4px;
  vertical-align: middle;
}

.collapse-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
  border-radius: 4px;
}

.collapse-btn:active {
  transform: scale(0.95);
}
